diff --git a/src/gausskernel/storage/access/transam/xlog.cpp b/src/gausskernel/storage/access/transam/xlog.cpp index 841468fbc9d15d2659bed35e8fb8268d7d1da5de..e46fd9e2eab75b24fde3799d8b367f5869034424 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,