From 2ca7da4773999ac34fb351fa47c06ae0ca6e1a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=9F=E6=89=BF=E5=BF=97?= <842536125@qq.com> Date: Wed, 20 Nov 2024 09:37:08 +0800 Subject: [PATCH] modified: src/gausskernel/ddes/adapter/ss_dms_bufmgr.cpp modified: src/gausskernel/ddes/adapter/ss_dms_callback.cpp modified: src/gausskernel/process/threadpool/knl_instance.cpp modified: src/gausskernel/storage/buffer/bufmgr.cpp modified: src/gausskernel/storage/smgr/segment/segbuffer.cpp modified: src/include/ddes/dms/ss_dms_recovery.h modified: src/include/knl/knl_thread.h modified: gausskernel/storage/buffer/bufmgr.cpp modified: gausskernel/storage/smgr/segment/segbuffer.cpp modified: gausskernel/ddes/adapter/ss_dms_bufmgr.cpp modified: gausskernel/storage/smgr/segment/segbuffer.cpp modified: segbuffer.cpp modified: gausskernel/ddes/adapter/ss_dms_bufmgr.cpp modified: gausskernel/storage/smgr/segment/segbuffer.cpp modified: ddes/adapter/ss_dms_bufmgr.cpp modified: storage/smgr/segment/segbuffer.cpp modified: gausskernel/ddes/adapter/ss_dms_bufmgr.cpp modified: gausskernel/storage/smgr/segment/segbuffer.cpp modified: src/gausskernel/ddes/adapter/ss_dms_bufmgr.cpp modified: src/gausskernel/storage/smgr/segment/segbuffer.cpp modified: gausskernel/ddes/adapter/ss_dms_bufmgr.cpp modified: gausskernel/storage/buffer/bufmgr.cpp modified: gausskernel/storage/smgr/segment/segbuffer.cpp modified: gausskernel/storage/buffer/bufmgr.cpp modified: gausskernel/ddes/adapter/ss_dms_bufmgr.cpp modified: gausskernel/ddes/adapter/ss_dms_callback.cpp modified: gausskernel/process/threadpool/knl_instance.cpp modified: gausskernel/storage/buffer/bufmgr.cpp modified: include/ddes/dms/ss_dms_recovery.h modified: src/gausskernel/ddes/adapter/ss_dms_callback.cpp modified: src/gausskernel/process/threadpool/knl_instance.cpp modified: src/gausskernel/storage/buffer/bufmgr.cpp modified: src/include/ddes/dms/ss_dms_recovery.h modified: src/gausskernel/ddes/adapter/ss_dms_bufmgr.cpp modified: src/gausskernel/storage/buffer/bufmgr.cpp modified: src/gausskernel/storage/smgr/segment/segbuffer.cpp modified: src/gausskernel/ddes/adapter/ss_dms_bufmgr.cpp modified: src/gausskernel/ddes/adapter/ss_dms_callback.cpp modified: src/gausskernel/process/threadpool/knl_instance.cpp modified: src/gausskernel/storage/buffer/bufmgr.cpp modified: src/gausskernel/storage/smgr/segment/segbuffer.cpp modified: src/include/ddes/dms/ss_dms_recovery.h --- .../ddes/adapter/ss_dms_bufmgr.cpp | 3 +-- src/gausskernel/storage/buffer/bufmgr.cpp | 19 ++++++++++++------- .../storage/smgr/segment/segbuffer.cpp | 4 +++- src/include/ddes/dms/ss_dms_recovery.h | 1 - src/include/knl/knl_thread.h | 3 +++ 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/gausskernel/ddes/adapter/ss_dms_bufmgr.cpp b/src/gausskernel/ddes/adapter/ss_dms_bufmgr.cpp index 41ae638dac..42f973f534 100644 --- a/src/gausskernel/ddes/adapter/ss_dms_bufmgr.cpp +++ b/src/gausskernel/ddes/adapter/ss_dms_bufmgr.cpp @@ -30,6 +30,7 @@ #include "utils/resowner.h" #include "ddes/dms/ss_dms_bufmgr.h" #include "ddes/dms/ss_reform_common.h" +#include "ddes/dms/ss_dms_recovery.h" #include "securec_check.h" #include "miscadmin.h" #include "access/double_write.h" @@ -477,12 +478,10 @@ Buffer DmsReadSegPage(Buffer buffer, LWLockMode mode, ReadBufferMode read_mode, if (buf_ctrl->state & BUF_IS_RELPERSISTENT_TEMP) { return buffer; } - if (!DmsCheckBufAccessible()) { *with_io = false; return 0; } - if (!DmsStartBufferIO(buf_desc, mode)) { if (!DmsCheckBufAccessible()) { *with_io = false; diff --git a/src/gausskernel/storage/buffer/bufmgr.cpp b/src/gausskernel/storage/buffer/bufmgr.cpp index f8967c8f79..5fa37ba9c6 100644 --- a/src/gausskernel/storage/buffer/bufmgr.cpp +++ b/src/gausskernel/storage/buffer/bufmgr.cpp @@ -88,6 +88,7 @@ #include "ddes/dms/ss_common_attr.h" #include "ddes/dms/ss_reform_common.h" #include "ddes/dms/ss_transaction.h" +#include "knl/knl_thread.h" const int ONE_MILLISECOND = 1; const int TEN_MICROSECOND = 10; @@ -2589,6 +2590,10 @@ Buffer ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber fork */ } else if (RecoveryInProgress()) { BlockNumber totalBlkNum = smgrnblocks_cached(smgr, forkNum); + /* when in failover, should return to worker thread exit */ + if (SS_IN_FAILOVER && SS_AM_BACKENDS_WORKERS) { + return InvalidBuffer; + } /* Update cached blocks */ if (totalBlkNum == InvalidBlockNumber || blockNum >= totalBlkNum) { @@ -2785,7 +2790,7 @@ found_branch: return InvalidBuffer; } /* when in failover, should return to worker thread exit */ - if ((SS_IN_FAILOVER) && ((t_thrd.role == WORKER) || (t_thrd.role == THREADPOOL_WORKER))) { + if (SS_IN_FAILOVER && SS_AM_BACKENDS_WORKERS) { SSUnPinBuffer(bufHdr); return InvalidBuffer; } @@ -3333,6 +3338,11 @@ retry_new_buffer: return buf; } + /* when in failover, should return to worker thread exit */ + if (SS_IN_FAILOVER && SS_AM_BACKENDS_WORKERS) { + ClearReadHint(buf->buf_id, true); + break; + } /* * Somebody could have pinned or re-dirtied the buffer while we were * doing the I/O and making the new hashtable entry. If so, we can't @@ -3353,11 +3363,6 @@ retry_new_buffer: ClearReadHint(buf->buf_id, true); break; } - /* when in failover, woker thread should return InvalidBuffer and exit */ - if (SS_IN_FAILOVER && ((t_thrd.role == WORKER) || (t_thrd.role == THREADPOOL_WORKER))) { - ClearReadHint(buf->buf_id, true); - break; - } } else { break; } @@ -6355,7 +6360,7 @@ retry: } bool with_io_in_progress = true; /* when in failover, should return to worker thread exit */ - if ((SS_IN_FAILOVER) && ((t_thrd.role == WORKER) || (t_thrd.role == THREADPOOL_WORKER))) { + if (SS_IN_FAILOVER && SS_AM_BACKENDS_WORKERS) { return; } if (IsSegmentBufferID(buf->buf_id)) { diff --git a/src/gausskernel/storage/smgr/segment/segbuffer.cpp b/src/gausskernel/storage/smgr/segment/segbuffer.cpp index 5d864da823..d8e1c06b43 100644 --- a/src/gausskernel/storage/smgr/segment/segbuffer.cpp +++ b/src/gausskernel/storage/smgr/segment/segbuffer.cpp @@ -34,6 +34,8 @@ #include "pgstat.h" #include "ddes/dms/ss_dms_bufmgr.h" #include "replication/ss_disaster_cluster.h" +#include "knl/knl_thread.h" + /* * Segment buffer, used for segment meta data, e.g., segment head, space map head. We separate segment * meta data buffer and normal data buffer (in bufmgr.cpp) to avoid potential dead locks. @@ -619,7 +621,7 @@ Buffer ReadBufferFast(SegSpace *spc, RelFileNode rnode, ForkNumber forkNum, Bloc return InvalidBuffer; } /* when in failover, should return to worker thread exit */ - if ((SS_IN_FAILOVER) && ((t_thrd.role == WORKER) || (t_thrd.role == THREADPOOL_WORKER))) { + if (SS_IN_FAILOVER && SS_AM_BACKENDS_WORKERS) { SSUnPinBuffer(bufHdr); return InvalidBuffer; } diff --git a/src/include/ddes/dms/ss_dms_recovery.h b/src/include/ddes/dms/ss_dms_recovery.h index 8cd55a0abb..27eaa958ae 100644 --- a/src/include/ddes/dms/ss_dms_recovery.h +++ b/src/include/ddes/dms/ss_dms_recovery.h @@ -66,7 +66,6 @@ SS_NORMAL_PRIMARY && g_instance.dms_cxt.SSRecoveryInfo.enableRealtimeBuildLogCtrl > 0) #define SS_STANDBY_ENABLE_TARGET_RTO (SS_NORMAL_STANDBY && \ SS_ONDEMAND_REALTIME_BUILD_NORMAL && g_instance.dms_cxt.SSRecoveryInfo.enableRealtimeBuildLogCtrl > 0) - #define REFORM_CTRL_VERSION 1 typedef struct st_reformer_ctrl { uint32 version; diff --git a/src/include/knl/knl_thread.h b/src/include/knl/knl_thread.h index 2a3dba1f43..559832eeb2 100755 --- a/src/include/knl/knl_thread.h +++ b/src/include/knl/knl_thread.h @@ -82,6 +82,9 @@ #define MAX_PATH_LEN 1024 extern const int g_reserve_param_num; #define PARTKEY_VALUE_MAXNUM 64 +#define SS_AM_BACKENDS_WORKERS (t_thrd.role == WORKER || \ + t_thrd.role == THREADPOOL_WORKER || \ + t_thrd.role == TRACK_STMT_CLEANER) typedef struct ResourceOwnerData* ResourceOwner; typedef struct logicalLog logicalLog; -- Gitee