Details
-
Bug
-
Status: Open (View Workflow)
-
Critical
-
Resolution: Unresolved
-
11.4
-
None
-
Can result in unexpected behaviour
-
Q1/2027 Replic. Maintenance
Description
I had AI analyze this test failure. Here is what it found:
When wsrep_slave_threads is increased while an applier thread is still exiting after an earlier decrease, the server creates no new applier. When the exiting thread is gone, fewer appliers run than wsrep_slave_threads says.
- SET GLOBAL wsrep_slave_threads=1 with 2 appliers running. wsrep_slave_count_change_update() sets wsrep_slave_count_change to -1.
- An applier applies its next write set. Wsrep_applier_service::check_exit_status() increments wsrep_slave_count_change to 0 and returns true, and the thread starts to exit.
- The thread is still counted in wsrep_running_applier_threads. The count goes down only at the end of the applier thread exit path in wsrep_mysqld.cc.
- SET GLOBAL wsrep_slave_threads=2 runs in this window. wsrep_slave_threads_update() computes 2 - 2 = 0 and creates no thread.
- The exiting thread decrements wsrep_running_applier_threads to 1. One applier runs, and wsrep_slave_threads is 2.
static void wsrep_slave_count_change_update () |
{
|
wsrep_slave_count_change = (wsrep_slave_threads - wsrep_running_applier_threads);
|
...
|
}
|
bool Wsrep_applier_service::check_exit_status() const |
{
|
bool ret= false; |
mysql_mutex_lock(&LOCK_wsrep_slave_threads);
|
if (wsrep_slave_count_change < 0) |
{
|
++wsrep_slave_count_change;
|
ret= true; |
}
|
mysql_mutex_unlock(&LOCK_wsrep_slave_threads);
|
return ret; |
}
|
The test galera.galera_multi_level_fk_ddl_update hits this window. Each part sets wsrep_slave_threads=2 on node 2 and sets it back to DEFAULT at the end. The cleanup DROP TABLE from node 1 makes one applier on node 2 exit, and the next part sets wsrep_slave_threads=2 at the same time. The failure occurred in 1 of 800 runs, with 16 test instances in parallel. Only one applier was left, it was held at the debug sync point by the TOI event, and the UPDATE was never applied.
|
11.4.14 (Debug), mtr output |
**** ERROR: failed while waiting for '' 'wsrep_apply_waits' = '178' ****
|
SHOW STATUS LIKE 'wsrep_apply_waits';
|
Variable_name Value
|
wsrep_apply_waits 177
|
SHOW PROCESSLIST;
|
Id User Host db Command Time State Info Progress
|
1 system user NULL Sleep 112 wsrep aborter idle NULL 0.000
|
333 root localhost:51472 test Query 0 starting SHOW PROCESSLIST 0.000
|
336 system user NULL Sleep 61 debug sync point: now NULL 0.000
|
|
11.4.14 (Debug), error log of node 2 |
2026-11-24 12:28:37 334 [Note] WSREP: Applier thread exiting ret: 0 thd: 334
|
2026-11-24 12:28:37 336 [Note] WSREP: Starting applier thread 336
|
2026-11-24 12:28:38 335 [Note] WSREP: Slave thread exiting on request.
|
2026-11-24 12:28:38 335 [Note] WSREP: Applier thread exiting ret: 0 thd: 335
|
No applier thread starts after thread 335 exits. The test runs without wsrep-debug, so the step where wsrep_slave_threads_update() computes 0 is from the code and is not in the log.
A test can avoid the window if it waits for wsrep_applier_thread_count to reach the lower value before it increases wsrep_slave_threads:
let $wait_condition = SELECT VARIABLE_VALUE = 1 |
FROM INFORMATION_SCHEMA.GLOBAL_STATUS |
WHERE VARIABLE_NAME = 'wsrep_applier_thread_count'; |
--source include/wait_condition.inc
|
SET GLOBAL wsrep_slave_threads=2; |
A possible server fix is to count the appliers that already consumed an exit request in wsrep_slave_count_change_update().
Created via the jira-create skill.