Skip to content

fix plugin semisync find minAck bug #509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

jiyfhust
Copy link

@jiyfhust jiyfhust commented Dec 15, 2023

As explanatory note shows:

Find the minimum ack which is smaller than given position. When more than
one slots are minimum acks, it returns the one has smallest index.

the return ack is " the minimum ack which is smaller than given position", but the minAck return a value which is the last index who is smaller than given position.

@mysql-oca-bot
Copy link

Hi, thank you for submitting this pull request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at https://oca.opensource.oracle.com/
Please make sure to include your MySQL bug system user (email) in the returned form.
Thanks

@jiyfhust
Copy link
Author

jiyfhust commented Dec 15, 2023

We can reproduce a case which has an unexpected result made by this bug by the steps shows:

1. deploy a 4 node mysql cluster, one acts as source, the other three as replica
2. on source node(master), make some configures:

mysql> show global status like "Rpl_semi_sync_master_clients";
+------------------------------+-------+
| Variable_name                | Value |
+------------------------------+-------+
| Rpl_semi_sync_master_clients | 3     |
+------------------------------+-------+
1 row in set (0.01 sec)

mysql> set global rpl_semi_sync_master_timeout = 100000000;
Query OK, 0 rows affected (0.00 sec)

mysql> set global rpl_semi_sync_master_wait_for_slave_count=4;
Query OK, 0 rows affected (0.00 sec)

mysql> set global binlog_order_commits = 0;
Query OK, 0 rows affected (0.00 sec)

mysql> show global variables like "%semi%";
+-------------------------------------------+------------+
| Variable_name                             | Value      |
+-------------------------------------------+------------+
| rpl_semi_sync_master_enabled              | ON         |
| rpl_semi_sync_master_timeout              | 100000000  |
| rpl_semi_sync_master_trace_level          | 32         |
| rpl_semi_sync_master_wait_for_slave_count | 4          |
| rpl_semi_sync_master_wait_no_slave        | ON         |
| rpl_semi_sync_master_wait_point           | AFTER_SYNC |
| rpl_semi_sync_slave_enabled               | ON         |
| rpl_semi_sync_slave_trace_level           | 32         |
+-------------------------------------------+------------+
8 rows in set (0.00 sec)

3. create three mysql client connections to master,named cli-1、cli-2、cli-3

4. for each of the three replica node(slave),create one mysql client connection, named sla-1、sla-2、sla-3, then on each replica node connection execute: stop slave.

mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.12 sec)

5. on source node(master) cli-1, we insert a record, the query will be blocked because there is no enough acks.

mysql> insert into t values(1, "a");

6. on replica node 3(slave) sla-3, we execute: start slave.

mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.22 sec)

7. on replica node 1(slave) sla-1, we execute: start slave.

mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.24 sec)

8. on replica node 2(slave) sla-2, we execute: start slave.

mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.19 sec)


9. on replica node 1(slave) sla-1, we execute: stop slave.

mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.10 sec)

10. on source node(master) cli-2, we insert a record, the query will be blocked because there is no enough acks.

mysql> insert into t values(2, "b");

11. on replica node 2(slave) sla-2, we execute: stop slave.

mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.09 sec)

12. on source node(master) cli-3, we insert a record, the query will be blocked because there is no enough acks.

mysql> insert into t values(3, "c");

13. create a new mysql client connection to source node(master), set rpl_semi_sync_master_wait_for_slave_count

mysql> set global rpl_semi_sync_master_wait_for_slave_count=3;
Query OK, 0 rows affected (0.01 sec)

14. then source cli-1(step 5) and source cli-2(step 10) both returned:

(step:5 source cli-1)
mysql> insert into t values(1, "a");
Query OK, 1 row affected (1 min 18.08 sec)

(step:10 source cli-2)
mysql> insert into t values(2, "b");
Query OK, 1 row affected (45.08 sec)

15. we check the data on source and replica nodes:

replica node 1(slave sla-1) :
mysql> select * from t;
+------+------+
| id   | name |
+------+------+
|    1 | a    |
+------+------+
1 row in set (0.00 sec)

replice node 2 (slave sla-2) :
mysql> select * from t;
+------+------+
| id   | name |
+------+------+
|    1 | a    |
|    2 | b    |
+------+------+
2 rows in set (0.00 sec)

replica node 3 (slave sla-3) :
mysql> select * from t;
+------+------+
| id   | name |
+------+------+
|    1 | a    |
|    2 | b    |
|    3 | c    |
+------+------+
3 rows in set (0.00 sec)

that is record (1, "a") inserted by source cli-1 is replicated to 3 replica nodes, while recode (2, "b") inserted by source cli-2 is replicated to only 2 replica nodes。

16. conslusion

because on source node,we set rpl_semi_sync_master_wait_for_slave_count = 3, so query inserting record (2, "b") should not return as expected.

@SKRR6773
Copy link

jpg-file

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle's Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment:
"I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it."
Thanks

@jiyfhust
Copy link
Author

Hi, thank you for your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle's Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment: "I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it." Thanks

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

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Your code has been assigned to an internal queue. Please follow
bug http://bugs.mysql.com/bug.php?id=113634 for updates.
Thanks

@jiyfhust jiyfhust deleted the fix_minack branch January 17, 2024 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants