1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
#
# Preparation
#
CREATE TABLE t1 (i INT NOT NULL, PRIMARY KEY (i)) ENGINE=InnoDB;
RESET MASTER;
SET @@global.rpl_semi_sync_master_timeout = 60000;
SET @@global.rpl_semi_sync_master_wait_no_slave = 1;
# It's okay to see "Killed" but we should not see "Timeout" in the log.
call mtr.add_suppression("Killed waiting for reply of binlog");
call mtr.add_suppression("Run function 'after_commit' in plugin 'rpl_semi_sync_master' failed");
call mtr.add_suppression("Run function 'after_sync' in plugin 'rpl_semi_sync_master' failed");
#
# Test wait point = AFTER_COMMIT
#
SET @@global.rpl_semi_sync_master_wait_point = AFTER_COMMIT;
# Make another connection to INSERT from.
SET GLOBAL rpl_semi_sync_master_enabled = 1;
# Go ahead and send the INSERT; it should block.
INSERT INTO t1 (i) VALUES (1);
# The INSERT thread should now be waiting.
SELECT state AS should_be_waiting
FROM information_schema.processlist WHERE id = @other_connection_id;
should_be_waiting
Waiting for semi-sync ACK from slave
# The insert should be visible to other threads
SELECT * FROM t1 ORDER BY 1;
i
1
# Kill the waiting thread; it should die immediately.
KILL @other_connection_id;
# Collect the error from the INSERT thread; it should be disconnected.
Got one of the listed errors
# Wait for INSERT thread to actually disappear (KILL closes connection
# before thread actually finishes its processing).
# The INSERT thread should now be gone.
SELECT state AS should_be_empty_set
FROM information_schema.processlist WHERE id = @other_connection_id;
should_be_empty_set
# The insert is still there
SELECT * FROM t1 ORDER BY 1;
i
1
# Make another connection to INSERT from.
# Go ahead and send the INSERT; it should block.
INSERT INTO t1 (i) VALUES (2);
# The INSERT thread should now be waiting.
SELECT state AS should_be_waiting
FROM information_schema.processlist WHERE id = @other_connection_id;
should_be_waiting
Waiting for semi-sync ACK from slave
# The insert should be visible to other threads
SELECT * FROM t1 ORDER BY 1;
i
1
2
# Now restart server
# Done restarting server
# Reset setting that were lost in restart
SET @@global.rpl_semi_sync_master_timeout = 60000;
SET @@global.rpl_semi_sync_master_wait_no_slave = 1;
# Check that row is still there
SELECT * FROM t1 ORDER BY 1;
i
1
2
#
# Test wait point = AFTER_SYNC
#
SET @@global.rpl_semi_sync_master_wait_point = AFTER_SYNC;
# Make another connection to INSERT from.
SET GLOBAL rpl_semi_sync_master_enabled = 1;
# Go ahead and send the INSERT; it should block.
INSERT INTO t1 (i) VALUES (3);
# The INSERT thread should now be waiting.
SELECT state AS should_be_waiting
FROM information_schema.processlist WHERE id = @other_connection_id;
should_be_waiting
Waiting for semi-sync ACK from slave
# The insert should NOT be visible to other threads
SELECT * FROM t1 ORDER BY 1;
i
1
2
# Kill the waiting thread; it should die immediately.
KILL @other_connection_id;
# Collect the error from the INSERT thread; it should be disconnected.
Got one of the listed errors
# Wait for INSERT thread to actually disappear (KILL closes connection
# before thread actually finishes its processing).
# The INSERT thread should now be gone.
SELECT state AS should_be_empty_set
FROM information_schema.processlist WHERE id = @other_connection_id;
should_be_empty_set
# The row inserted is there
SELECT * FROM t1 ORDER BY 1;
i
1
2
3
# Make another connection to INSERT from.
# Go ahead and send the INSERT; it should block.
INSERT INTO t1 (i) VALUES (4);
# The INSERT thread should now be waiting.
SELECT state AS should_be_waiting
FROM information_schema.processlist WHERE id = @other_connection_id;
should_be_waiting
Waiting for semi-sync ACK from slave
# The insert should NOT be visible to other threads
SELECT * FROM t1 ORDER BY 1;
i
1
2
3
# Now restart server
# Done restarting server
# Reset setting that were lost in restart
SET @@global.rpl_semi_sync_master_timeout = 60000;
SET @@global.rpl_semi_sync_master_wait_no_slave = 1;
# But the row inserted is there
SELECT * FROM t1 ORDER BY 1;
i
1
2
3
4
#
# Cleanup
#
SET GLOBAL rpl_semi_sync_master_enabled = 0;
DROP TABLE t1;
SET @@global.rpl_semi_sync_master_timeout = 10000;
SET @@global.rpl_semi_sync_master_wait_no_slave = 1;
SET @@global.rpl_semi_sync_master_wait_point = AFTER_COMMIT;
|