マスターのイベント (更新/挿入/変更) がバイナリ ログに正確に記録されるのはいつですか?
- マスターサーバーで起動すると、bin ログに書き込まれます
- マスターで開始して完了すると、ログに記録されます
具体的には、ALTER の場合の動作を知りたいです。回答が 1 の場合、マスターで ALTER が開始されているため、通常の状態ではマスターとスレーブの間でラグは発生しません。
マスターのイベント (更新/挿入/変更) がバイナリ ログに正確に記録されるのはいつですか?
具体的には、ALTER の場合の動作を知りたいです。回答が 1 の場合、マスターで ALTER が開始されているため、通常の状態ではマスターとスレーブの間でラグは発生しません。
Non-transactional statements are written to the binary log immediately. For MySQL 5+, this means any statement against a storage engine that doesn't support transactions are written immediately.
You shouldn't be executing statements against a non-transactional table inside a transaction though.
Transactional statements are written to the binary log when the transaction is committed. For MySQL 5+, this means any statement against a transactional table.
Currently, ALTER TABLE forces an implicit commit, so this will immediately be written to the binary log. According to MySQL documentation:
Binary logging is done immediately after a statement completes but before any locks are released or any commit is done. This ensures that the log is logged in execution order.