diff --git a/src/gausskernel/storage/ipc/procarray.cpp b/src/gausskernel/storage/ipc/procarray.cpp index 4e97936cf..794fa7821 100644 --- a/src/gausskernel/storage/ipc/procarray.cpp +++ b/src/gausskernel/storage/ipc/procarray.cpp @@ -4674,6 +4674,8 @@ TransactionId ListAllSessionGttFrozenxids(int maxSize, ThreadId *pids, Transacti } ThreadPoolSessControl *sessCtrl = g_threadPoolControler->GetSessionCtrl(); + AutoMutexLock alock(sessCtrl->GetSessionCtrlLock()); + alock.lock(); const knl_sess_control *sessList = sessCtrl->GetSessionList(); const knl_sess_control *currSess = sessList; while (currSess != nullptr) { @@ -4694,6 +4696,7 @@ TransactionId ListAllSessionGttFrozenxids(int maxSize, ThreadId *pids, Transacti } currSess = currSess->next; } + alock.unLock(); if (maxSize > 0) { *n = i; diff --git a/src/include/threadpool/threadpool_sessctl.h b/src/include/threadpool/threadpool_sessctl.h index d035e0437..b8c6c88e0 100644 --- a/src/include/threadpool/threadpool_sessctl.h +++ b/src/include/threadpool/threadpool_sessctl.h @@ -88,9 +88,9 @@ public: return m_activelist; } - inline pthread_mutex_t GetSessionCtrlLock() + inline pthread_mutex_t* GetSessionCtrlLock() { - return m_sessCtrlock; + return &m_sessCtrlock; } private: