Bug #99425 Semi-sync better to be aware of datacenter
Submitted: 3 May 2020 17:22 Modified: 4 May 2020 4:40
Reporter: dennis GAO (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S4 (Feature request)
Version:8.0.19 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[3 May 2020 17:22] dennis GAO
Description:
It is a future request.
MySQL semi-sync plugin has variable rpl_semi_sync_master_wait_for_slave_count, which can control the master to wait for at least number of slaves to response ack.
For cross datacenter situation, such as two datacenter, we hope the semi-sync can ensure the master transaction has been received by the slave in the other datacenter.
If only use rpl_semi_sync_master_wait_for_slave_count, we must cover all slaves in the datacenter of the master, which may lead master to wait too many slaves and has worse tolerance for net environment.

How to repeat:
Two datacenter and setup two mysqls for each datacenter.
Suppose these four mysqls are m1, s1, s2, s3.
m1 and s1 in datacenter1.
s2 and s3 in datacenter2.
The replication relationship is m1->s1, m1->s2, m1->s3.

In order to ensure the transaction of m1 to replica to datacenter2, we should set rpl_semi_sync_master_wait_for_slave_count to be 2, actually we can finish the master commit if any of s2 or s3 response to master, no need to wait for s1. 

Suggested fix:
It is better to introduce the available zoon for mysql, such as a datacenter is a available zoon, and mysql can config to wait at least number of available zoon slaves for master commit.

For detail, each mysql has new options:
1. available_zoon_id, which indicate the available zoon of this mysql.
   It is a global variable and can not be dynamic changed.
2. rpl_semi_sync_master_wait_for_slave_az_count, which indicate the master only need to wait how many of available zoon slaves for commit.

The master will maintain two ack_container, one for rpl_semi_sync_master_wait_for_slave_count, and one for rpl_semi_sync_master_wait_for_slave_az_count.

Anyone ck_container satisfied can lead master to finish commit.

For tow datacenter four mysqls situation mentioned above, we can set rpl_semi_sync_master_wait_for_slave_count to be 2 and set rpl_semi_sync_master_wait_for_slave_az_count to be 1.
If s2 or s3 response fast than s1, the master can finish the commit more soon.
[3 May 2020 17:26] dennis GAO
adding the patch to implement above feature request 

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: available_zoon_id-v1.diff (text/x-patch), 27.77 KiB.

[4 May 2020 4:40] MySQL Verification Team
Hello dennis GAO,

Thank you for the reasonable feature request and contribution.

regards,
Umesh