From 6a3d7ca3a14416be1b472cdfa12d0d5878561ad9 Mon Sep 17 00:00:00 2001 From: Chunling Wang Date: Tue, 28 Sep 2021 12:30:02 +0800 Subject: [PATCH] Fix acuqrie/relesase lock for t_thrd.shemem_ptr_cxt.XLogCtl->LogwrtResult --- src/gausskernel/storage/access/transam/xlog.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gausskernel/storage/access/transam/xlog.cpp b/src/gausskernel/storage/access/transam/xlog.cpp index 841468fbc9..e46fd9e2ea 100755 --- a/src/gausskernel/storage/access/transam/xlog.cpp +++ b/src/gausskernel/storage/access/transam/xlog.cpp @@ -2873,8 +2873,13 @@ static void XLogWrite(const XLogwrtRqst &WriteRqst, bool flexible) /* We should always be inside a critical section here */ Assert(t_thrd.int_cxt.CritSectionCount > 0); + /* use volatile pointer to prevent code rearrangement */ + volatile XLogCtlData* xlogctl = t_thrd.shemem_ptr_cxt.XLogCtl; + // Update local LogwrtResult (caller probably did this already, but...) + SpinLockAcquire(&xlogctl->info_lck); *t_thrd.xlog_cxt.LogwrtResult = t_thrd.shemem_ptr_cxt.XLogCtl->LogwrtResult; + SpinLockRelease(&xlogctl->info_lck); /* * Since successive pages in the xlog cache are consecutively allocated, -- Gitee