2

マスターのイベント (更新/挿入/変更) がバイナリ ログに正確に記録されるのはいつですか?

  1. マスターサーバーで起動すると、bin ログに書き込まれます
  2. マスターで開始して完了すると、ログに記録されます

具体的には、ALTER の場合の動作を知りたいです。回答が 1 の場合、マスターで ALTER が開始されているため、通常の状態ではマスターとスレーブの間でラグは発生しません。

4

1 に答える 1

1

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.

于 2012-05-15T16:11:01.237 に答える