mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
- Description:
- Before 10.3.8 semisync was a plugin that is built into the server with
MDEV-13073,starting with commit cbc71485e2
.
There are still some usage of `rpl_semi_sync_master` in mtr.
Note:
- To recognize the replica in the `dump_thread`, replica is creating
local variable `rpl_semi_sync_slave` (the keyword of plugin) in
function `request_transmit`, that is catched by primary in
`is_semi_sync_slave()`. This is the user variable and as such not
related to the obsolete plugin.
- Found in `sys_vars.all_vars` and `rpl_semi_sync_wait_point` tests,
usage of plugins `rpl_semi_sync_master`, `rpl_semi_sync_slave`.
The former test is disabled by default (`sys_vars/disabled.def`)
and marked as `obsolete`, however this patch will remove the queries.
- Add cosmetic fixes to semisync codebase
Reviewer: <brandon.nesterenko@mariadb.com>
Closes PR #2528, PR #2380
252 lines
7.1 KiB
Plaintext
252 lines
7.1 KiB
Plaintext
source include/not_embedded.inc;
|
|
source include/have_innodb.inc;
|
|
|
|
#
|
|
# This test the rpl_semi_sync_master_wait_point functionality
|
|
# and illustrates the differences between the two values AFTER_COMMIT and
|
|
# AFTER_SYNC
|
|
#
|
|
|
|
--echo #
|
|
--echo # Preparation
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (i INT NOT NULL, PRIMARY KEY (i)) ENGINE=InnoDB;
|
|
RESET MASTER;
|
|
|
|
let $save_timeout = `select @@global.rpl_semi_sync_master_timeout`;
|
|
let $save_wait_no_slave = `select @@global.rpl_semi_sync_master_wait_no_slave`;
|
|
let $save_wait_point = `select @@global.rpl_semi_sync_master_wait_point`;
|
|
|
|
SET @@global.rpl_semi_sync_master_timeout = 60000;
|
|
SET @@global.rpl_semi_sync_master_wait_no_slave = 1;
|
|
|
|
--echo # 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");
|
|
|
|
--echo #
|
|
--echo # Test wait point = AFTER_COMMIT
|
|
--echo #
|
|
SET @@global.rpl_semi_sync_master_wait_point = AFTER_COMMIT;
|
|
|
|
--echo # Make another connection to INSERT from.
|
|
connect (other,localhost,root,,);
|
|
connection other;
|
|
let $other_connection_id = `SELECT CONNECTION_ID()`;
|
|
|
|
connection default;
|
|
|
|
--disable_query_log
|
|
eval SET @other_connection_id = $other_connection_id;
|
|
--enable_query_log
|
|
|
|
SET GLOBAL rpl_semi_sync_master_enabled = 1;
|
|
|
|
--echo # Go ahead and send the INSERT; it should block.
|
|
connection other;
|
|
send INSERT INTO t1 (i) VALUES (1);
|
|
|
|
connection default;
|
|
|
|
let $wait_condition =
|
|
SELECT COUNT(*) > 0 AS should_be_true
|
|
FROM information_schema.processlist
|
|
WHERE id = @other_connection_id
|
|
AND state = "Waiting for semi-sync ACK from slave";
|
|
--source include/wait_condition.inc
|
|
|
|
--echo # The INSERT thread should now be waiting.
|
|
SELECT state AS should_be_waiting
|
|
FROM information_schema.processlist WHERE id = @other_connection_id;
|
|
|
|
--echo # The insert should be visible to other threads
|
|
SELECT * FROM t1 ORDER BY 1;
|
|
|
|
--echo # Kill the waiting thread; it should die immediately.
|
|
KILL @other_connection_id;
|
|
|
|
--echo # Collect the error from the INSERT thread; it should be disconnected.
|
|
connection other;
|
|
--error 2013,ER_CONNECTION_KILLED
|
|
reap;
|
|
|
|
connection default;
|
|
|
|
--echo # Wait for INSERT thread to actually disappear (KILL closes connection
|
|
--echo # before thread actually finishes its processing).
|
|
let $wait_condition =
|
|
SELECT COUNT(*) = 0 AS should_be_true
|
|
FROM information_schema.processlist
|
|
WHERE id = @other_connection_id;
|
|
--source include/wait_condition.inc
|
|
|
|
--echo # The INSERT thread should now be gone.
|
|
SELECT state AS should_be_empty_set
|
|
FROM information_schema.processlist WHERE id = @other_connection_id;
|
|
|
|
--echo # The insert is still there
|
|
SELECT * FROM t1 ORDER BY 1;
|
|
|
|
connection default;
|
|
disconnect other;
|
|
|
|
--echo # Make another connection to INSERT from.
|
|
connect (other,localhost,root,,);
|
|
connection other;
|
|
let $other_connection_id = `SELECT CONNECTION_ID()`;
|
|
connection default;
|
|
--disable_query_log
|
|
eval SET @other_connection_id = $other_connection_id;
|
|
--enable_query_log
|
|
|
|
--echo # Go ahead and send the INSERT; it should block.
|
|
connection other;
|
|
send INSERT INTO t1 (i) VALUES (2);
|
|
|
|
connection default;
|
|
|
|
let $wait_condition =
|
|
SELECT COUNT(*) > 0 AS should_be_true
|
|
FROM information_schema.processlist
|
|
WHERE id = @other_connection_id
|
|
AND state = "Waiting for semi-sync ACK from slave";
|
|
--source include/wait_condition.inc
|
|
|
|
--echo # The INSERT thread should now be waiting.
|
|
SELECT state AS should_be_waiting
|
|
FROM information_schema.processlist WHERE id = @other_connection_id;
|
|
|
|
--echo # The insert should be visible to other threads
|
|
SELECT * FROM t1 ORDER BY 1;
|
|
|
|
--echo # Now restart server
|
|
--source include/restart_mysqld.inc
|
|
--echo # Done restarting server
|
|
|
|
--echo # 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;
|
|
|
|
--echo # Check that row is still there
|
|
SELECT * FROM t1 ORDER BY 1;
|
|
|
|
disconnect other;
|
|
|
|
--echo #
|
|
--echo # Test wait point = AFTER_SYNC
|
|
--echo #
|
|
SET @@global.rpl_semi_sync_master_wait_point = AFTER_SYNC;
|
|
|
|
--echo # Make another connection to INSERT from.
|
|
connect (other,localhost,root,,);
|
|
connection other;
|
|
let $other_connection_id = `SELECT CONNECTION_ID()`;
|
|
|
|
connection default;
|
|
|
|
--disable_query_log
|
|
eval SET @other_connection_id = $other_connection_id;
|
|
--enable_query_log
|
|
|
|
SET GLOBAL rpl_semi_sync_master_enabled = 1;
|
|
|
|
--echo # Go ahead and send the INSERT; it should block.
|
|
connection other;
|
|
send INSERT INTO t1 (i) VALUES (3);
|
|
|
|
connection default;
|
|
|
|
let $wait_condition =
|
|
SELECT COUNT(*) > 0 AS should_be_true
|
|
FROM information_schema.processlist
|
|
WHERE id = @other_connection_id
|
|
AND state = "Waiting for semi-sync ACK from slave";
|
|
--source include/wait_condition.inc
|
|
|
|
--echo # The INSERT thread should now be waiting.
|
|
SELECT state AS should_be_waiting
|
|
FROM information_schema.processlist WHERE id = @other_connection_id;
|
|
|
|
--echo # The insert should NOT be visible to other threads
|
|
SELECT * FROM t1 ORDER BY 1;
|
|
|
|
--echo # Kill the waiting thread; it should die immediately.
|
|
KILL @other_connection_id;
|
|
|
|
--echo # Collect the error from the INSERT thread; it should be disconnected.
|
|
connection other;
|
|
--error 2013,ER_CONNECTION_KILLED
|
|
reap;
|
|
|
|
connection default;
|
|
|
|
--echo # Wait for INSERT thread to actually disappear (KILL closes connection
|
|
--echo # before thread actually finishes its processing).
|
|
let $wait_condition =
|
|
SELECT COUNT(*) = 0 AS should_be_true
|
|
FROM information_schema.processlist
|
|
WHERE id = @other_connection_id;
|
|
--source include/wait_condition.inc
|
|
|
|
--echo # The INSERT thread should now be gone.
|
|
SELECT state AS should_be_empty_set
|
|
FROM information_schema.processlist WHERE id = @other_connection_id;
|
|
|
|
--echo # The row inserted is there
|
|
SELECT * FROM t1 ORDER BY 1;
|
|
|
|
connection default;
|
|
disconnect other;
|
|
|
|
--echo # Make another connection to INSERT from.
|
|
connect (other,localhost,root,,);
|
|
connection other;
|
|
let $other_connection_id = `SELECT CONNECTION_ID()`;
|
|
connection default;
|
|
--disable_query_log
|
|
eval SET @other_connection_id = $other_connection_id;
|
|
--enable_query_log
|
|
|
|
--echo # Go ahead and send the INSERT; it should block.
|
|
connection other;
|
|
send INSERT INTO t1 (i) VALUES (4);
|
|
|
|
connection default;
|
|
|
|
let $wait_condition =
|
|
SELECT COUNT(*) > 0 AS should_be_true
|
|
FROM information_schema.processlist
|
|
WHERE id = @other_connection_id
|
|
AND state = "Waiting for semi-sync ACK from slave";
|
|
--source include/wait_condition.inc
|
|
|
|
--echo # The INSERT thread should now be waiting.
|
|
SELECT state AS should_be_waiting
|
|
FROM information_schema.processlist WHERE id = @other_connection_id;
|
|
|
|
--echo # The insert should NOT be visible to other threads
|
|
SELECT * FROM t1 ORDER BY 1;
|
|
|
|
--echo # Now restart server
|
|
--source include/restart_mysqld.inc
|
|
--echo # Done restarting server
|
|
|
|
--echo # 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;
|
|
|
|
--echo # But the row inserted is there
|
|
SELECT * FROM t1 ORDER BY 1;
|
|
|
|
disconnect other;
|
|
|
|
--echo #
|
|
--echo # Cleanup
|
|
--echo #
|
|
SET GLOBAL rpl_semi_sync_master_enabled = 0;
|
|
DROP TABLE t1;
|
|
|
|
eval SET @@global.rpl_semi_sync_master_timeout = $save_timeout;
|
|
eval SET @@global.rpl_semi_sync_master_wait_no_slave = $save_wait_no_slave;
|
|
eval SET @@global.rpl_semi_sync_master_wait_point = $save_wait_point;
|