From ca0862b157ebef78d4298ffce06e888add7de434 Mon Sep 17 00:00:00 2001 From: shenzhengntu <503699317@qq.com> Date: Tue, 27 Jun 2023 14:22:06 +0800 Subject: [PATCH] mutex control parallel replay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code Source From: Self Code Description: 【Optional】 Jira: #【Optional】 市场项目编号(名称):【Optional】 --- src/backend/access/transam/pagehashqueue.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/backend/access/transam/pagehashqueue.c b/src/backend/access/transam/pagehashqueue.c index 2449669..4da069a 100644 --- a/src/backend/access/transam/pagehashqueue.c +++ b/src/backend/access/transam/pagehashqueue.c @@ -490,6 +490,7 @@ void pushSlaveReplayQueue(int pageNum) { SpinLockRelease(&PageHashQueueShmem->mutex); WakeupFlushWork(); } + while(pageNum > CompletedTaskNum()) { pg_usleep(1000L); } @@ -662,12 +663,14 @@ void SortPageQueue(void) { BufferTag* QueuePushPage(void) { uint32_t gpushpos; bool hasData = false; - SpinLockAcquire(&PageHashQueueShmem->mutex); - if (PageHashQueueShmem->ready == true && PageHashQueueShmem->gpushpos < PageHashQueueShmem->gpos) { - hasData = true; - gpushpos = PageHashQueueShmem->gpushpos++; + if (PageHashQueueShmem->ready == true) { + SpinLockAcquire(&PageHashQueueShmem->mutex); + if (PageHashQueueShmem->ready == true && PageHashQueueShmem->gpushpos < PageHashQueueShmem->gpos) { + hasData = true; + gpushpos = PageHashQueueShmem->gpushpos++; + } + SpinLockRelease(&PageHashQueueShmem->mutex); } - SpinLockRelease(&PageHashQueueShmem->mutex); if (hasData == false) { return NULL; } else {