Bug #111075 I_S.PROCESSLIST shows misleading information for replica threads

Submitted: 18 May 2023 13:24 Modified: 18 May 2023 13:53
Reporter: Kamil Holubicki (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[18 May 2023 13:24] Kamil Holubicki
Description:
I_S.PROCESSLIST shows misleading information for replica threads. It shows 'Query' while the thread is idle.

How to repeat:
1. Setup async replication (2 servers).
2. Execute any query on Source.
3. On Replica execute SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; the result is like:

+----+-----------------+-----------------+------+---------+------+----------------------------------------------------------+----------------------------------------------+---------+-----------+---------------+
| ID | USER            | HOST            | DB   | COMMAND | TIME | STATE                                                    | INFO                                         | TIME_MS | ROWS_SENT | ROWS_EXAMINED |
+----+-----------------+-----------------+------+---------+------+----------------------------------------------------------+----------------------------------------------+---------+-----------+---------------+
| 24 | root            | localhost:43060 | NULL | Query   |    0 | executing                                                | SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST |       2 |         0 |             0 |
| 16 | system user     |                 | NULL | Connect |  416 | Waiting for an event from Coordinator                    | NULL                                         |  416287 |         0 |             0 |
| 17 | system user     |                 | NULL | Connect |  416 | Waiting for an event from Coordinator                    | NULL                                         |  416284 |         0 |             0 |
| 18 | system user     |                 | NULL | Connect |  416 | Waiting for an event from Coordinator                    | NULL                                         |  416281 |         0 |             0 |
| 13 | system user     | connecting host | NULL | Connect |  416 | Waiting for source to send event                         | NULL                                         |  416294 |         0 |             0 |
| 14 | system user     |                 | NULL | Query   |  289 | Replica has read all relay log; waiting for more updates | NULL                                         |  288877 |         0 |             0 |
|  7 | event_scheduler | localhost       | NULL | Daemon  |  548 | Waiting on empty queue                                   | NULL                                         |  548297 |         0 |             0 |
| 23 | root            | localhost:43056 | NULL | Sleep   |    3 |                                                          | NULL                                         |    2531 |         1 |             1 |
| 15 | system user     |                 | NULL | Query   |  289 | Waiting for an event from Coordinator                    | NULL                                         |  288867 |         0 |             0 |
+----+-----------------+-----------------+------+---------+------+----------------------------------------------------------+----------------------------------------------+---------+-----------+---------------+
9 rows in set (0,01 sec)

Suggested fix:
This is because in replica flow thd->set_command(COM_SLEEP); is never executed.
In a regular client flow it is set in dispatch_command().

Suggested fix attached.
[18 May 2023 13:25] Kamil Holubicki
proposed fix

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: command.patch (text/x-patch), 956 bytes.

[18 May 2023 13:53] MySQL Verification Team
Hi Mr. Holubicki,

Thank you for your bug report.

Verified as reported.

Thanks also for your patch !!!

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.