Bug #97560 idle & caught up slave has old query shown in "Info" section of processlist...
Submitted: 8 Nov 2019 12:32
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.7.29 OS:Any
Assigned to: CPU Architecture:Any

[8 Nov 2019 12:32] Shane Bester
Description:
Slave is fully caught up and no problem,  but it's showing stale info in processlist...   It should be blank.

mysql> show slave status \G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 127.0.0.1
                  Master_User: root
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: binlog.000566
          Read_Master_Log_Pos: 10685956
               Relay_Log_File: fc30-relay-bin.001132
                Relay_Log_Pos: 10686163
        Relay_Master_Log_File: binlog.000566
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 10685956
              Relay_Log_Space: 10686453
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
                  Master_UUID: d16a795c-0220-11ea-a310-000d6179f72b
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: d16a795c-0220-11ea-a310-000d6179f72b:1-56830
            Executed_Gtid_Set: d16a795c-0220-11ea-a310-000d6179f72b:1-56830
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
1 row in set (0.00 sec)

mysql> show processlist;
+----+-------------+-----------------+------+---------+------+--------------------------------------------------------+-------------------------------------------------------------------------------+
| Id | User        | Host            | db   | Command | Time | State                                                  | Info                                                                          |
+----+-------------+-----------------+------+---------+------+--------------------------------------------------------+-------------------------------------------------------------------------------+
|  4 | system user |                 | NULL | Connect |  634 | Waiting for master to send event                       | NULL                                                                          |
|  5 | system user |                 | NULL | Connect |  204 | Slave has read all relay log; waiting for more updates | CREATE USER IF NOT EXISTS 'user2'@'%' IDENTIFIED WITH 'mysql_native_password' |
|  7 | root        | localhost:47716 | NULL | Sleep   |   30 |                                                        | NULL                                                                          |
|  8 | root        | localhost:48056 | NULL | Query   |    0 | starting                                               | show processlist                                                              |
+----+-------------+-----------------+------+---------+------+--------------------------------------------------------+-------------------------------------------------------------------------------+
4 rows in set (0.00 sec)

Thread stacks also confirmed server is idle.

How to repeat:
Setup RBR/GTID replication.

On master:

yes "drop user if exists 'user1'@'%'; create user if not exists 'user1'@'%' IDENTIFIED WITH 'mysql_native_password';" | mysql -uroot -h127.0.0.1 -P3306 

after a short while ctrl-c this,  and watch the slave catchup, and check processlist and see the last executed query still there.

Suggested fix:
clear the old query.
[13 Nov 2020 2:02] Ye Jinrong,MySQL ACE
I meet this bug too, but at 8.0.22 version.

There are 4 nodes in MGR.
mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
| group_replication_applier | 2d9a8e67-2004-11eb-a38c-e4434ba52b50 | ndb1        |        3390 | ONLINE       | SECONDARY   | 8.0.22         |
| group_replication_applier | 72fd3fd5-1ffd-11eb-a584-e4434ba52b50 | ndb1        |        3380 | ONLINE       | PRIMARY     | 8.0.22         |
| group_replication_applier | 91f738e8-2000-11eb-a043-e4434ba522fc | ndb2        |        3380 | ONLINE       | SECONDARY   | 8.0.22         |
| group_replication_applier | dd850604-2002-11eb-9b4c-e4434ba522fc | ndb2        |        3390 | ONLINE       | SECONDARY   | 8.0.22         |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+

execute alter user command in primary node
mysql> alter user identified by 'yejr';

then in one Secondary node
mysql>select @@server_uuid;
+--------------------------------------+
| @@server_uuid                        |
+--------------------------------------+
| 91f738e8-2000-11eb-a043-e4434ba522fc |
+--------------------------------------+

mysql> pager cat - | grep ALTER
mysql> show processlist;
|     12 | system user |            | NULL | Query   |     30 | Slave has read all relay log; waiting for more updates | ALTER USER 'yejr'@'%' IDENTIFIED WITH 'mysql_native_password' AS '*9DB91006131E32B22135599033C6A9C19 |

the state will not change until i execute some other command in Primary node.