[MDEV-162] Enhanced semisync replication Created: 2012-02-23 Updated: 2019-03-20 Resolved: 2014-12-23 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Replication |
| Fix Version/s: | 10.1.3 |
| Type: | Task | Priority: | Major |
| Reporter: | Rasmus Johansson (Inactive) | Assignee: | Kristian Nielsen |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | pf1, replication | ||
| Attachments: |
|
||||||||||||
| Issue Links: |
|
||||||||||||
| Description |
|
Enhanced semi-synchronous replication does COMMIT in the following way: 1. Prepare the transaction in the storage engine(s). 2. Write the transaction to the binlog, flush the binlog to disk. 3. Wait for at least one slave to acknowledge the reception of the binlog 4. Commit the transaction to the storage engine(s). This is different from normal semi-synchronous replication, where steps (3) This task is about implementing enhanced semi-synchronous replication in a way A benefit of enhanced semi-synchronous replication is that a transaction does For more discussion see http://www.mysqlperformanceblog.com/2012/01/19/how-does-semisynchronous-mysql-replication-work/ Implementation in MariaDB group commitIn MariaDB group commit, a group of commits queue up while waiting for the Once the previous group finishes, we have in step (2) a list of commits that To implement enhanced semi-synchronous replication, we simply add a step just The mutexes must be chained, meaning that we must take the next lock before
See the code in sql/log.cc, MYSQL_BIN_LOG::trx_group_commit_leader() for The stage (3) should be added as another kind of hook (semi-sync replication http://code.google.com/p/enhanced-semi-sync-replication/ When --rpl_semi_sync_master_wait_before_commit=1, semi-sync plugin can use the Crash scenariosIf a master crashes before a transaction T is written into the binlog, that If T was written (and synced) into binlog, but not yet acknowledged by any If T was acknowledged by at least one slave, then we know that T exists both If a slave crashes during the commit on master, nothing special should In this case the situation is much as with normal semisync. Commits will be Pending XID issueOne issue that needs to be dealt with is the potential deadlock described in http://bugs.mysql.com/bug.php?id=44058 The problem is that when the server wants to rotate the binlog, it takes the This can be worked around, of course — as eg. done in the Google enhanced I would prefer to instead solve the root problem — that server needs to stall https://mariadb.atlassian.net/browse/MDEV-181 |
| Comments |
| Comment by Kristian Nielsen [ 2012-06-22 ] |
|
Adding a bit to the estimate, as the semisync code has shown itself to be complex and rather bug-ridden. So better anticipate a couple extra days to deal with this. |
| Comment by Pavel Ivanov [ 2013-11-14 ] |
|
It looks like this bug lived long enough that one can just back-port the implementation of rpl_semi_sync_master_wait_point from 5.7.2, see http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_rpl_semi_sync_master_wait_point. |
| Comment by VAROQUI Stephane [ 2014-04-03 ] |
|
Details about some improvement merge into mysql : |
| Comment by Jonas Oreland [ 2014-10-08 ] |
|
FYI: i've just completed implementing this (and a few other things on semi-sync)...and will submit patch as soon as it's review on our side. /Jonas |
| Comment by Sergei Golubchik [ 2014-10-12 ] |
|
jonaso, you can submit a pull request on github or merge request on launchpad or attach a patch here to the issue. Whatever you prefer. |
| Comment by Jonas Oreland [ 2014-10-20 ] |
|
patch on top of 10.0.15 |
| Comment by Jonas Oreland [ 2014-11-12 ] |
|
Hi again Kristian, I don't know if you looked at my submission, but I haven't heard anything. The problem is that code dead-locks with "high" concurrency. My suggested solution is to make the change described in http://my-replication-life.blogspot.se/2013/09/dump-thread-enhancement.html. Do you think the proposed solution sounds reasonable ? Furthermore, the 5.7 code base has been refactored quite a lot as compared to mariadb. Most of is very good. /Jonas |
| Comment by Jonas Oreland [ 2014-11-24 ] |
|
ping Kristian! 1) What do you think about my comment above. 2) I started on the http://my-replication-life.blogspot.se/2013/09/dump-thread-enhancement.html, But, if doing the refactorings, this will be a quite big/intrusive patch. /Jonas |
| Comment by Kristian Nielsen [ 2014-12-03 ] |
|
Jonas, I did see any of your comments until by accident just now. |
| Comment by Jonas Oreland [ 2014-12-04 ] |
|
Hi again, I've now backported the dump thread enhancements, I'm still interested to hear if you think my comments from 2014-11-12 15:37 is correct. I haven't (yet) tested if that patch fixes the live-lock that occured previously. /Jonas |
| Comment by Kristian Nielsen [ 2014-12-09 ] |
|
> I'm still interested to hear if you think my comments from 2014-11-12 15:37 is correct. I think it sounds right. LOCK_log should not be needed by binlog dump threads, as the binlog is write-only. (There is one thing to check though. When a binlog file is closed, a flag is updated in the Format_description event at the start of the binlog. But I don't expect it could cause any problem). BTW, it seems to me that group commit also should not need LOCK_log to ensure only one thread at a time is doing (group) commit. It could be a new mutex like LOCK_after_binlog_sync. But I suppose there is no longer much contention on LOCK_log, so no need to introduce another mutex, unless we discover another deadlock issue. I will take a look at the patch you attached to this bug. |
| Comment by Kristian Nielsen [ 2014-12-23 ] |
|
Pushed to 10.1. Thanks, Jonas! |