mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
364b15c090
This patch fixes two problems that may arise when changing the value of wsrep_slave_threads: 1) Threads may be leaked if wsrep_slave_threads is changed repeatedly. Specifically, when changing the number of slave threads, we keep track of wsrep_slave_count_change, the number of slaves to start / stop. The problem arises when wsrep_slave_count_change is updated before slaves had a chance to exit (threads may take some time to exit, as they exit only after commiting one more replication event). The fix is to update wsrep_slave_count_change such that it reflects the number of threads that already exited or are scheduled to exit. 2) Attempting to set out of range value for wsrep_slave_threads (below 1 / above 512) results in wsrep_slave_count_change to be computed based on the out of range value, even though a warning is generated and wsrep_slave_threads is set to a truncated value. wsrep_slave_count_change is computed in wsrep_slave_threads_check(), which is called before mysql checks for valid range. Fix is to update wsrep_count_change whenever wsrep_slave_threads is updated with a valid value.
42 lines
1.3 KiB
Text
42 lines
1.3 KiB
Text
CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB;
|
|
SET GLOBAL wsrep_slave_threads = 10;
|
|
SET GLOBAL wsrep_slave_threads = 1;
|
|
INSERT INTO t1 VALUES (1);
|
|
SET GLOBAL wsrep_slave_threads = 10;
|
|
SELECT COUNT(*) = 11 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
|
|
COUNT(*) = 11
|
|
1
|
|
SET GLOBAL wsrep_slave_threads = 20;
|
|
SELECT COUNT(*) = 21 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
|
|
COUNT(*) = 21
|
|
1
|
|
SET GLOBAL wsrep_slave_threads = 1;
|
|
INSERT INTO t1 VALUES (1);
|
|
INSERT INTO t1 VALUES (2);
|
|
INSERT INTO t1 VALUES (3);
|
|
INSERT INTO t1 VALUES (4);
|
|
INSERT INTO t1 VALUES (5);
|
|
INSERT INTO t1 VALUES (6);
|
|
INSERT INTO t1 VALUES (7);
|
|
INSERT INTO t1 VALUES (8);
|
|
INSERT INTO t1 VALUES (9);
|
|
SET GLOBAL wsrep_slave_threads = 10;
|
|
SET GLOBAL wsrep_slave_threads = 0;
|
|
Warnings:
|
|
Warning 1292 Truncated incorrect wsrep_slave_threads value: '0'
|
|
INSERT INTO t1 VALUES (10);
|
|
INSERT INTO t1 VALUES (11);
|
|
INSERT INTO t1 VALUES (12);
|
|
INSERT INTO t1 VALUES (13);
|
|
INSERT INTO t1 VALUES (14);
|
|
INSERT INTO t1 VALUES (15);
|
|
INSERT INTO t1 VALUES (16);
|
|
INSERT INTO t1 VALUES (17);
|
|
INSERT INTO t1 VALUES (18);
|
|
INSERT INTO t1 VALUES (19);
|
|
INSERT INTO t1 VALUES (20);
|
|
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user';
|
|
COUNT(*) = 2
|
|
1
|
|
SET GLOBAL wsrep_slave_threads = 1;
|
|
DROP TABLE t1;
|