Description:
The pfs_thread changes when a thread uses Srv_session. Since Srv_session is used in group_replication_reset_member_actions(), calling this function will set the pfs_thread.processlist_id to NULL. The relevant code in Srv_session::detach() shows that the pfs_thread is reset:
```
bool Srv_session::detach() {
......
#ifdef HAVE_PSI_THREAD_INTERFACE
set_psi(nullptr);
#endif
......
}
static void set_psi(THD *thd) {
struct PSI_thread *psi = PSI_THREAD_CALL(get_thread)();
PSI_THREAD_CALL(set_thread_id)(psi, thd ? thd->thread_id() : 0);
PSI_THREAD_CALL(set_thread_THD)(psi, thd);
}
```
How to repeat:
mysql> select * from performance_schema.threads where processlist_id = connection_id()\G
*************************** 1. row ***************************
THREAD_ID: 53
NAME: thread/sql/one_connection
TYPE: FOREGROUND
PROCESSLIST_ID: 16
PROCESSLIST_USER: root
PROCESSLIST_HOST: localhost
PROCESSLIST_DB: NULL
PROCESSLIST_COMMAND: Query
PROCESSLIST_TIME: 0
PROCESSLIST_STATE: executing
PROCESSLIST_INFO: select * from performance_schema.threads where processlist_id = connection_id()
PARENT_THREAD_ID: NULL
ROLE: NULL
INSTRUMENTED: YES
HISTORY: YES
CONNECTION_TYPE: SSL/TLS
THREAD_OS_ID: 69122
RESOURCE_GROUP: USR_default
EXECUTION_ENGINE: PRIMARY
1 row in set (0.01 sec)
mysql> install plugin group_replication soname 'group_replication.so';
Query OK, 0 rows affected (0.05 sec)
mysql> select group_replication_reset_member_actions();
+------------------------------------------+
| group_replication_reset_member_actions() |
+------------------------------------------+
| OK |
+------------------------------------------+
1 row in set (0.02 sec)
mysql> select * from performance_schema.threads where processlist_id = connection_id()\G
Empty set (0.00 sec)
mysql> select * from performance_schema.threads where thread_id = 53\G
*************************** 1. row ***************************
THREAD_ID: 53
NAME: thread/sql/one_connection
TYPE: BACKGROUND
PROCESSLIST_ID: NULL
PROCESSLIST_USER: root
PROCESSLIST_HOST: localhost
PROCESSLIST_DB: NULL
PROCESSLIST_COMMAND: NULL
PROCESSLIST_TIME: 0
PROCESSLIST_STATE: statistics
PROCESSLIST_INFO: select * from performance_schema.threads where thread_id = 53
PARENT_THREAD_ID: NULL
ROLE: NULL
INSTRUMENTED: YES
HISTORY: YES
CONNECTION_TYPE: SSL/TLS
THREAD_OS_ID: 69122
RESOURCE_GROUP: USR_default
EXECUTION_ENGINE: PRIMARY
1 row in set (0.00 sec)
Description: The pfs_thread changes when a thread uses Srv_session. Since Srv_session is used in group_replication_reset_member_actions(), calling this function will set the pfs_thread.processlist_id to NULL. The relevant code in Srv_session::detach() shows that the pfs_thread is reset: ``` bool Srv_session::detach() { ...... #ifdef HAVE_PSI_THREAD_INTERFACE set_psi(nullptr); #endif ...... } static void set_psi(THD *thd) { struct PSI_thread *psi = PSI_THREAD_CALL(get_thread)(); PSI_THREAD_CALL(set_thread_id)(psi, thd ? thd->thread_id() : 0); PSI_THREAD_CALL(set_thread_THD)(psi, thd); } ``` How to repeat: mysql> select * from performance_schema.threads where processlist_id = connection_id()\G *************************** 1. row *************************** THREAD_ID: 53 NAME: thread/sql/one_connection TYPE: FOREGROUND PROCESSLIST_ID: 16 PROCESSLIST_USER: root PROCESSLIST_HOST: localhost PROCESSLIST_DB: NULL PROCESSLIST_COMMAND: Query PROCESSLIST_TIME: 0 PROCESSLIST_STATE: executing PROCESSLIST_INFO: select * from performance_schema.threads where processlist_id = connection_id() PARENT_THREAD_ID: NULL ROLE: NULL INSTRUMENTED: YES HISTORY: YES CONNECTION_TYPE: SSL/TLS THREAD_OS_ID: 69122 RESOURCE_GROUP: USR_default EXECUTION_ENGINE: PRIMARY 1 row in set (0.01 sec) mysql> install plugin group_replication soname 'group_replication.so'; Query OK, 0 rows affected (0.05 sec) mysql> select group_replication_reset_member_actions(); +------------------------------------------+ | group_replication_reset_member_actions() | +------------------------------------------+ | OK | +------------------------------------------+ 1 row in set (0.02 sec) mysql> select * from performance_schema.threads where processlist_id = connection_id()\G Empty set (0.00 sec) mysql> select * from performance_schema.threads where thread_id = 53\G *************************** 1. row *************************** THREAD_ID: 53 NAME: thread/sql/one_connection TYPE: BACKGROUND PROCESSLIST_ID: NULL PROCESSLIST_USER: root PROCESSLIST_HOST: localhost PROCESSLIST_DB: NULL PROCESSLIST_COMMAND: NULL PROCESSLIST_TIME: 0 PROCESSLIST_STATE: statistics PROCESSLIST_INFO: select * from performance_schema.threads where thread_id = 53 PARENT_THREAD_ID: NULL ROLE: NULL INSTRUMENTED: YES HISTORY: YES CONNECTION_TYPE: SSL/TLS THREAD_OS_ID: 69122 RESOURCE_GROUP: USR_default EXECUTION_ENGINE: PRIMARY 1 row in set (0.00 sec)