Tuesday, December 15, 2009

MySQL 5.5 and semi-sync replication are here

MySQL 5.5 is here with several new features including semi-sync replication. The MySQL team has been getting a lot done lately. I know because I get many bug and feature request status updates. They did a lot of work on semi-sync because their implementation was a rewrite rather than a port of the Google patch. It had to be done that way to maintain code quality. Those of us who maintain large patches against MySQL frequently do things the convenient way rather than the right way to simplify patch maintenance.

Read the MySQL manual to understand what semi-sync does. It is not synchronous replication. With semi-sync each connection to a master can lose at most one transaction when the master crashes. This reduces but does not eliminate the problem of transaction loss on a master crash. Semi-sync also limits a busy connection so that it cannot commit faster than a slave can receive its transactions.

Additional references for this include:

2 comments:

  1. Hi

    Thanks for the nice resources about semi-sync.

    I have a doubt regarding your claim that "With semi-sync each connection to a master can lose at most one transaction when the master crashes"

    MySQL manual says that "a thread that performs a transaction commit on the master blocks after the commit is done and waits until at least one semisynchronous slave acknowledges that it has received all events for the transaction, or until a timeout occurs. "

    This doesn't seem to support your claim.

    Consider an example with a maseter and three slaves (S1,S2,S3)

    Now suppose there are three transactions.

    After commiting transaction (T1) on master the thread blocks until one of the slave receives the events for T1. Assume slave S1 does this.

    Similarly for T2(S2 receives the events for T2) and T3 (S3 receives the events for T3).

    Now suppose the master crashes. Each slave can potentially lose more than one transaction (two transactions in our example, S1 loses T2 and T3).

    Can you please tell me where I got the concept of semi-sync wrong.

    ReplyDelete
  2. Transactions are serialized in the binlog. For you example assume the order is T1, T2, T3. For a slave to receive T3 it must have received T1 and T2.

    ReplyDelete

 
Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.