David Griffiths wrote:
Basically, the slave will try to "catch up" when it restarts.From reading the docs, a binary log is an efficient representation of all data-modifying SQL that is run on the master database. I was unable to figure out what happens if a slave is interrupted while in the middle of processing a binary log.
When a binary log is applied to a slave database, what happens if the machine or database dies half way through the log?
If I recall correctly, the binary log uses transactions as it's basic units. I'm not even sure if the slave will see statement 3 before statement 4, but I know it definitely will not act on it in any way.For example, with InnoDB, say the following statements are run and stored in the binary log:
--------------------------- 1) INSERT INTO table_a (column_a, column_b, ...) VALUES (...);
2) COMMIT;
3) UPDATE table_a SET column_b = 'some_value' WHERE column_c = 'something_else';
4) COMMIT; -----------------------------
The slave-machine (also using InnoDB tables) start processing the binary
log. Statement 1 and 2 are processed, but it dies before Statement 3 (UPDATE
table_a...) is executed.
If you restart the slave, would it start the binary log back at theThe slave won't try to reperform actions that are already processed. You can relax regarding unique attributes.
beginning, or is the offset inside the file stored in the database so that
the slave database starts at Statement 3? Or would the whole log be
re-processed (potentially causing problems with inserting rows with unique
keys)?
How does this work with MyISAM?In essentially the same way. As each statement is basically bound with BEGIN and COMMIT statements, each statement is processed by the slave after it successfully completes on the master.
Regards,Thanks, David
Chris
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]