-
Marc Alff authored
PROCESSLIST_INFO Before this fix, SELECT PROCESSLIST_INFO from performance_schema.threads; could return bad data for the column. 1) The data returned could be NULL even when the thread is currently executing a statement, instead of returning the query text. 2) The data returned could also contain invalid data. The root cause for 1) is that entering a new stage during the query execution causes spurious changes in PFS_thread::m_processlist_lock, which is used to protect both PROCESSLIST_STATE and PROCESSLIST_INFO. The root cause for 2) is that the thread instrumentation does not make a copy of the query text but uses the original query test pointer directly. This pointer can become invalid when the query ends and memory is freed. This fix implements different dedicated locks with PFS_thread::m_processlist_state_lock and PFS_thread::m_processlist_info_lock, so that a change in one attribute avoids causing spurious NULL when reading the other attribute. This fix now capture a copy of the processlist info, in PFS_thread::m_processlist_info, which is then safe to read even after the query ends.
Marc Alff authoredPROCESSLIST_INFO Before this fix, SELECT PROCESSLIST_INFO from performance_schema.threads; could return bad data for the column. 1) The data returned could be NULL even when the thread is currently executing a statement, instead of returning the query text. 2) The data returned could also contain invalid data. The root cause for 1) is that entering a new stage during the query execution causes spurious changes in PFS_thread::m_processlist_lock, which is used to protect both PROCESSLIST_STATE and PROCESSLIST_INFO. The root cause for 2) is that the thread instrumentation does not make a copy of the query text but uses the original query test pointer directly. This pointer can become invalid when the query ends and memory is freed. This fix implements different dedicated locks with PFS_thread::m_processlist_state_lock and PFS_thread::m_processlist_info_lock, so that a change in one attribute avoids causing spurious NULL when reading the other attribute. This fix now capture a copy of the processlist info, in PFS_thread::m_processlist_info, which is then safe to read even after the query ends.
Loading