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.