Bug #121350 SQL RESTART is not exempted from Group Replication consistency waits
Description:
The Group Replication transaction-begin hook holds commands while configured
consistency work is pending. It explicitly bypasses operational commands such as
`STOP GROUP_REPLICATION`, `SHUTDOWN`, `KILL`, status queries, and selected
`SET`/`RESET` operations. `SQLCOM_RESTART_SERVER` is absent from that bypass
list, although `RESTART` has the same operational need to remain available as
`SHUTDOWN`.
How to repeat:
Use **two disposable** MySQL 8.4.11 servers on an isolated network, with no
production traffic. Start node1/node2 with distinct `server-id` values 101/102,
`log-bin`, `gtid-mode=ON`, `enforce-gtid-consistency=ON`, `binlog-format=ROW`,
`log-replica-updates=ON`, and `mysql-native-password=ON`. Make their XCom addresses `node1:33061` and
`node2:33061` resolvable only within that network. In the tested container
topology mysqld is PID 1; `MYSQLD_PARENT_PID=0` permits the SQL `RESTART`
supervisor check. This test does **not** claim an external supervisor relaunched
the process.
1. On **each fresh node**, run the following SQL, replacing `<this-node>`
with `node1` or `node2`. The UUID is a synthetic test-group UUID, and the
recovery password is disposable. The `RESET` below removes disjoint
initialization GTIDs only in these **new, never-reused** nodes; never run
it on an existing database.
```sql
INSTALL PLUGIN group_replication SONAME 'group_replication.so';
SET SQL_LOG_BIN=0;
CREATE USER 'edbf_recovery'@'%' IDENTIFIED WITH mysql_native_password
BY 'Synthetic-Gr1!';
GRANT REPLICATION SLAVE, BACKUP_ADMIN, CONNECTION_ADMIN,
GROUP_REPLICATION_STREAM ON *.* TO 'edbf_recovery'@'%';
SET SQL_LOG_BIN=1;
CHANGE REPLICATION SOURCE TO SOURCE_USER='edbf_recovery',
SOURCE_PASSWORD='Synthetic-Gr1!' FOR CHANNEL 'group_replication_recovery';
SET GLOBAL group_replication_group_name='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee';
SET GLOBAL group_replication_local_address='<this-node>:33061';
SET GLOBAL group_replication_group_seeds='node1:33061,node2:33061';
SET GLOBAL group_replication_ip_allowlist='AUTOMATIC';
SET GLOBAL group_replication_single_primary_mode=ON;
SET GLOBAL group_replication_enforce_update_everywhere_checks=OFF;
SET GLOBAL group_replication_start_on_boot=OFF;
RESET BINARY LOGS AND GTIDS;
```
Then, on node1 run `SET GLOBAL group_replication_bootstrap_group=ON;
START GROUP_REPLICATION; SET GLOBAL group_replication_bootstrap_group=OFF;`.
On node2 run `START GROUP_REPLICATION;`. Confirm two `ONLINE` rows in
`performance_schema.replication_group_members`.
2. On node1 create and populate the replicated table:
```sql
CREATE DATABASE my13;
CREATE TABLE my13.t(id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO my13.t VALUES (1);
```
Wait until node2 reads one row. In a persistent node2 session run
`SET SESSION group_replication_consistency='EVENTUAL'; LOCK TABLES my13.t
READ; SELECT SLEEP(60); UNLOCK TABLES;` and keep that session open.
3. Insert `INSERT INTO my13.t VALUES (2)` on node1. On node2, wait until
`COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE` in
`performance_schema.replication_group_member_stats` is at least 1 for
`MEMBER_ID=@@server_uuid`. Start
`SELECT group_replication_set_as_primary('<node2 server_uuid>')` on node1
asynchronously. Wait until node2's `performance_schema.events_stages_current`
reports `stage/group_rpl/Primary Election: applying buffered transactions`.
4. On node2, a control session runs
`SET SESSION group_replication_consistency='BEFORE_ON_PRIMARY_FAILOVER';
SET @control=1; SELECT @control;` and returns `1` immediately. In a
**different** node2 session, execute
`SET SESSION group_replication_consistency='BEFORE_ON_PRIMARY_FAILOVER';
RESTART;` and leave it waiting.
5. From another node2 connection, query
`SELECT STATE,INFO FROM information_schema.processlist WHERE INFO='RESTART';`
twice, at least three seconds apart. Then kill only the test connection
holding `SELECT SLEEP(60)`/the table lock, and observe the election and
`RESTART` statement complete. Do not issue this test against an existing
group or an unrelated connection.
## Actual result
Both members reached `ONLINE`; the target member reported one queued remote
transaction and entered the primary-election backlog stage. The `SET` control
returned immediately. `RESTART` remained in this processlist state before and
after a three-second delay:
```text
Executing hook on transaction begin.|RESTART
```
After the table-lock connection was killed, primary election completed and the
`RESTART` client returned success. Current source separately shows that
`SHUTDOWN` is in the bypass list while `RESTART` is not.
The measured hold was 3.237 seconds. Neither a server crash nor a successful
external process relaunch was observed; the reproduced behavior is the SQL
command waiting in the GR transaction-begin hook.
## Expected result
`RESTART` should remain available under the same safety rule as `SHUTDOWN`, or
the server should document and bound why restart must wait.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: The Group Replication transaction-begin hook holds commands while configured consistency work is pending. It explicitly bypasses operational commands such as `STOP GROUP_REPLICATION`, `SHUTDOWN`, `KILL`, status queries, and selected `SET`/`RESET` operations. `SQLCOM_RESTART_SERVER` is absent from that bypass list, although `RESTART` has the same operational need to remain available as `SHUTDOWN`. How to repeat: Use **two disposable** MySQL 8.4.11 servers on an isolated network, with no production traffic. Start node1/node2 with distinct `server-id` values 101/102, `log-bin`, `gtid-mode=ON`, `enforce-gtid-consistency=ON`, `binlog-format=ROW`, `log-replica-updates=ON`, and `mysql-native-password=ON`. Make their XCom addresses `node1:33061` and `node2:33061` resolvable only within that network. In the tested container topology mysqld is PID 1; `MYSQLD_PARENT_PID=0` permits the SQL `RESTART` supervisor check. This test does **not** claim an external supervisor relaunched the process. 1. On **each fresh node**, run the following SQL, replacing `<this-node>` with `node1` or `node2`. The UUID is a synthetic test-group UUID, and the recovery password is disposable. The `RESET` below removes disjoint initialization GTIDs only in these **new, never-reused** nodes; never run it on an existing database. ```sql INSTALL PLUGIN group_replication SONAME 'group_replication.so'; SET SQL_LOG_BIN=0; CREATE USER 'edbf_recovery'@'%' IDENTIFIED WITH mysql_native_password BY 'Synthetic-Gr1!'; GRANT REPLICATION SLAVE, BACKUP_ADMIN, CONNECTION_ADMIN, GROUP_REPLICATION_STREAM ON *.* TO 'edbf_recovery'@'%'; SET SQL_LOG_BIN=1; CHANGE REPLICATION SOURCE TO SOURCE_USER='edbf_recovery', SOURCE_PASSWORD='Synthetic-Gr1!' FOR CHANNEL 'group_replication_recovery'; SET GLOBAL group_replication_group_name='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'; SET GLOBAL group_replication_local_address='<this-node>:33061'; SET GLOBAL group_replication_group_seeds='node1:33061,node2:33061'; SET GLOBAL group_replication_ip_allowlist='AUTOMATIC'; SET GLOBAL group_replication_single_primary_mode=ON; SET GLOBAL group_replication_enforce_update_everywhere_checks=OFF; SET GLOBAL group_replication_start_on_boot=OFF; RESET BINARY LOGS AND GTIDS; ``` Then, on node1 run `SET GLOBAL group_replication_bootstrap_group=ON; START GROUP_REPLICATION; SET GLOBAL group_replication_bootstrap_group=OFF;`. On node2 run `START GROUP_REPLICATION;`. Confirm two `ONLINE` rows in `performance_schema.replication_group_members`. 2. On node1 create and populate the replicated table: ```sql CREATE DATABASE my13; CREATE TABLE my13.t(id INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO my13.t VALUES (1); ``` Wait until node2 reads one row. In a persistent node2 session run `SET SESSION group_replication_consistency='EVENTUAL'; LOCK TABLES my13.t READ; SELECT SLEEP(60); UNLOCK TABLES;` and keep that session open. 3. Insert `INSERT INTO my13.t VALUES (2)` on node1. On node2, wait until `COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE` in `performance_schema.replication_group_member_stats` is at least 1 for `MEMBER_ID=@@server_uuid`. Start `SELECT group_replication_set_as_primary('<node2 server_uuid>')` on node1 asynchronously. Wait until node2's `performance_schema.events_stages_current` reports `stage/group_rpl/Primary Election: applying buffered transactions`. 4. On node2, a control session runs `SET SESSION group_replication_consistency='BEFORE_ON_PRIMARY_FAILOVER'; SET @control=1; SELECT @control;` and returns `1` immediately. In a **different** node2 session, execute `SET SESSION group_replication_consistency='BEFORE_ON_PRIMARY_FAILOVER'; RESTART;` and leave it waiting. 5. From another node2 connection, query `SELECT STATE,INFO FROM information_schema.processlist WHERE INFO='RESTART';` twice, at least three seconds apart. Then kill only the test connection holding `SELECT SLEEP(60)`/the table lock, and observe the election and `RESTART` statement complete. Do not issue this test against an existing group or an unrelated connection. ## Actual result Both members reached `ONLINE`; the target member reported one queued remote transaction and entered the primary-election backlog stage. The `SET` control returned immediately. `RESTART` remained in this processlist state before and after a three-second delay: ```text Executing hook on transaction begin.|RESTART ``` After the table-lock connection was killed, primary election completed and the `RESTART` client returned success. Current source separately shows that `SHUTDOWN` is in the bypass list while `RESTART` is not. The measured hold was 3.237 seconds. Neither a server crash nor a successful external process relaunch was observed; the reproduced behavior is the SQL command waiting in the GR transaction-begin hook. ## Expected result `RESTART` should remain available under the same safety rule as `SHUTDOWN`, or the server should document and bound why restart must wait.