Comments on: How Does Semisynchronous MySQL Replication Work? https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/ Fri, 16 Feb 2024 22:19:21 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: Juan Felipe Betancur Uribe https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-968749 Mon, 16 Jul 2012 15:40:03 +0000 https://www.percona.com/blog/?p=8302#comment-968749 Hi Baron. I’ve been looking an asynchronous replication solution for MySQL and this looks like what I need, but I would like your help clarifying a couple of doubts I have:

1) According to with I read, the Semisynchronous replication guarantee that at least 1 slave will have the transaction commited, is this mean that the semisynchronous replication becomes synchronous for at least 2 servers? (the master and 1 slave)?

2) Can I configure Semisynchronous replication for MySQL Server version: 5.0.83-community MySQL Community Edition (GPL)?

Thanks a lot for this post !!!
JFBU

]]>
By: Gregory Steulet https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-901471 Tue, 20 Mar 2012 22:54:31 +0000 https://www.percona.com/blog/?p=8302#comment-901471 Thanks for your feedback. I traced the sentence in the blog and I’ll make further investigations on this topic and update the blog asap.

]]>
By: Baron Schwartz https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-900249 Sat, 17 Mar 2012 14:40:23 +0000 https://www.percona.com/blog/?p=8302#comment-900249 The official documentation agrees with Mark. The important phrase is “a transaction commit on the master blocks AFTER the commit is done.”

Mark knows what he’s talking about – he was part of the MySQL team at Google that created semisynchronous replication.

]]>
By: Gregory Steulet https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-900216 Sat, 17 Mar 2012 12:34:02 +0000 https://www.percona.com/blog/?p=8302#comment-900216 Official MySQL documentation says the following :

“If semisynchronous replication is enabled on the master side and there is at least one semisynchronous slave, 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. ”
..
“The slave acknowledges receipt of a transaction’s events only after the events have been written to its relay log and flushed to disk. ”

“Compared to asynchronous replication, semisynchronous replication provides improved data integrity. When a commit returns successfully, it is known that the data exists in at least two places” – (cf http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html)

Of course if timeout occurs (which is by default set to 10sec), replication goes back to asynchronous.

]]>
By: Mark Callaghan https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-899386 Thu, 15 Mar 2012 23:16:49 +0000 https://www.percona.com/blog/?p=8302#comment-899386 This is not correct. With semi-sync the protocol is:
1) commit to master
2) wait for a slave to ack it
3) return to the user

“Basically, what semi-synchronous replication does is ensuring that a transaction/event has been written to at least one slave’s relay log and flushed to disk before doing the commit on the master node.”

]]>
By: Gregory Steulet https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-899385 Thu, 15 Mar 2012 23:12:22 +0000 https://www.percona.com/blog/?p=8302#comment-899385 Hi Mark,

Which part of the following article is wrong according to you ?

http://www.dbi-services.com/index.php/blog/entry/mysql-data-high-availability-with-semi-synchronous-replication

Thanks for your feedback, best regards

]]>
By: Gregory Steulet https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-899383 Thu, 15 Mar 2012 23:11:19 +0000 https://www.percona.com/blog/?p=8302#comment-899383 Hi Mark,

Which part of the following article is wrong according to you ?

http://www.mysqlperformanceblog.com/2012/01/19/how-does-semisynchronous-mysql-replication-work/

Thanks for your feedback, best regards

]]>
By: jayaram.pagoti https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-898206 Tue, 13 Mar 2012 12:35:08 +0000 https://www.percona.com/blog/?p=8302#comment-898206 What happens, If we delete the present running relay-log file in slave.

]]>
By: Baron Schwartz https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-883838 Wed, 01 Feb 2012 01:53:11 +0000 https://www.percona.com/blog/?p=8302#comment-883838 Thousands of people have many years of experience with MySQL replication. A few people have months of experience with Tungsten and Galera (a.k.a. Percona XtraDB Cluster), and I am sure we will learn a lot more after they mature more, but in principle they have fewer inherent obstacles to being reliable and robust.

]]>
By: Laurent https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-883637 Tue, 31 Jan 2012 15:50:41 +0000 https://www.percona.com/blog/?p=8302#comment-883637 Hi,

Currently analyzing different existing solutions to secure our web architecture using 3 mysql production servers and read your article which I found very interesting.
Like you said, I would really be interested to know people who put semi sync replication in production on large mysql databases and so don’t hesitate to contact us to share your throughts and experience 🙂
For the moment after evaluating semi sync replication (lots of problems with combining it to master/master circular replication and haproxy load balancing queries in front of mysql servers) and others open source solutions (tungsten / galera), i’m still wondering if there is any which is reliable and allows to have data integrity, high availability and easy failover with MySQL ?

Would be happy to have your thoughts/comments about this !

]]>
By: Henrik Ingo https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-878858 Sat, 21 Jan 2012 17:23:41 +0000 https://www.percona.com/blog/?p=8302#comment-878858 At the same time I always like to remind people, that actually using Galera in a multi-master mode is an option, or bonus if you will. If you are worried (or have actual issues) about the optimistic locking, you can always just fall back to writing to a single node. That will give you exactly the same behavior as a single node MySQL, including same performance, and more robust and simple HA than any of the other alternatives that currently exist. To use multi-master capabilities for scale-out is just an option on top of that.

]]>
By: Baron Schwartz https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-878846 Sat, 21 Jan 2012 16:26:14 +0000 https://www.percona.com/blog/?p=8302#comment-878846 I think you make a very good point: a benefit of Percona XtraDB Cluster, or for that matter generic Galera + generic InnoDB, is said to be an existing technology that you know and love; no need to learn a lot of new skills. But the fact that it uses optimistic concurrency control in a distributed fashion is a change to be aware of. We need real-world experience to see how this works out.

]]>
By: Mark Callaghan https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-878836 Sat, 21 Jan 2012 15:50:11 +0000 https://www.percona.com/blog/?p=8302#comment-878836 I agree, it is all about probability. Semi-sync can lose data in theory and in practice. Sync replication only loses it in practice. (from bugs and people making mistakes). It is more interesting to talk about this in terms of the chance of losing transactions but that data takes time to collect.

There is another way to lose transactions — performance degradation. Some implementations of sync replication will also lose transactions by not allowing them to commit because the extra latency cannot be tolerated by the application or because optimistic concurrency control leads to too many aborts. This is much more likely for workloads with hotspots. I hope that most of these problems can be resolved by redesigning applications.

]]>
By: Peter Zaitsev https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-878830 Sat, 21 Jan 2012 15:32:11 +0000 https://www.percona.com/blog/?p=8302#comment-878830 Hi,

I believe with Asynchronous replication (ewen with Semi synchronous) you will get the problem of nodes getting out of sync and either slave is ahead or master has data while slave does not. This goes back to Two General’s problem I believe
http://en.wikipedia.org/wiki/Two_Generals%27_Problem

The solution for this is to maintain some cluster “state” where the node has to do a suicide if it encourages the problem while applying the changes the cluster has already agreed to.

This is a theory though which sets on 100% guaranties of data consistency. While it is possible in theory due to software bugs, people mistakes, complicated faults everything can fail and data loss can occur and we just should be working with probabilities and chances. For some case MySQL replication (even without Semi Sync) is just fine.

]]>
By: Mark Callaghan https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-878824 Sat, 21 Jan 2012 15:05:37 +0000 https://www.percona.com/blog/?p=8302#comment-878824 The question should be about whether the enhanced semi-sync patch breaks it. The google patch did not. Slaves don’t get to ack until they read it from the master’s binlog and the binlog is not written until commit is done (PREPARE and COMMIT for InnoDB) on the master. I assume enhanced semi-sync follows the same sequence but I have not looked at that code.

]]>
By: Kristian Nielsen https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-878759 Sat, 21 Jan 2012 10:13:06 +0000 https://www.percona.com/blog/?p=8302#comment-878759 > However it can cause another problem of slave having transaction committed
> when master have never committed it, if there is a problem on commit.

> The race in this case is that if there is a problem on the master the slave
> has the transactions.

This should not be possible. The transaction is prepared and written to binlog
before being sent to the slave. The prepare ensures that the commit will not
fail, and the prepare + write to binlog ensures that XA recovery will commit
the transaction later if master crashes before it can commit. So slave will
never get commits that don’t exist on the master.

Or does the Google patches break this?

]]>
By: Mark Callaghan https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-878517 Fri, 20 Jan 2012 20:05:36 +0000 https://www.percona.com/blog/?p=8302#comment-878517 Oh, no. Someone is wrong on the internet! This author makes the wrong assumption that Baron warns about above.

http://www.dbi-services.com/index.php/blog/entry/mysql-data-high-availability-with-semi-synchronous-replication
http://xkcd.com/386/

]]>
By: Mark Callaghan https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-878447 Fri, 20 Jan 2012 15:48:54 +0000 https://www.percona.com/blog/?p=8302#comment-878447 Semi-sync has a few features that made it useful to one deployment (one large & busy deployment):
* it makes it much more likely that fewer transactions will be lost when a master disappears
* it throttles busy clients to run no faster than master-slave networking

These are not guarantees but they still made things better when the inevitable failures occurred as fewer transactions would be lost. I will distinguish between protect data (old transactions) and protect recent transactions. We already have great protection for old transactions (backup, etc). Semi-sync provides better protection for recent transactions.

I like the idea of Enhanced Semi-Sync but suspect that the implementation will make commit stalls even worse as it probably increases the duration of the time for which prepare_commit_mutex is held. This needs to be integrated with the changes for group commit so that we can do:
1) get many transactions into state PREPARED on the master
2) write the PREPARED transactions into the binlog
3) wait for one slave to ACK all of them
4) commit on the master

The race in this case is that if there is a problem on the master the slave has the transactions. I would promote the slave to the master in that case. There is also a race if the master blows up and then the slave is unable to apply the transactions. I think that is unlikely and am willing to perform manual intervention to recover in that case.

Now I just need to figure out if Kristian and MariaDB think this is interesting.

]]>
By: Peter Zaitsev https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-878379 Fri, 20 Jan 2012 12:22:59 +0000 https://www.percona.com/blog/?p=8302#comment-878379 Holger,

MySQL Replication is great and this is what made MySQL so successful in Web world. It is relatively simple low overhead on master and works with great distances and large networks. The problems come when people start to look to build truly highly available solutions with replication which also require consistency and no data loss.

Semi Synchronous replication in fact can be enough for many applications but it just needs to be well understood it does not guaranty no data loss by design.

]]>
By: Holger Thiel https://www.percona.com/blog/how-does-semisynchronous-mysql-replication-work/#comment-878378 Fri, 20 Jan 2012 12:16:22 +0000 https://www.percona.com/blog/?p=8302#comment-878378 I think it is not so bad to have an asynchronous replication. And the semi synchronous replication is not so bad. If you want to have synchronous replication you could use distributed transactions instead. And there we have similar problems …

]]>