From c2f454597de7021750fc94df310c1591d079bec3 Mon Sep 17 00:00:00 2001 From: movead Date: Tue, 7 Nov 2023 07:56:13 +0800 Subject: [PATCH] add a function which will show the wal keeper aggainst wal clean --- src/common/backend/catalog/builtin_funcs.ini | 4 + src/common/backend/utils/init/globals.cpp | 2 +- .../storage/access/transam/xlog.cpp | 107 +++++++++++++++++- .../storage/access/transam/xlogfuncs.cpp | 79 +++++++++++++ src/gausskernel/storage/replication/slot.cpp | 6 +- src/include/access/xlog.h | 34 ++++++ src/include/catalog/pg_proc.h_for_llt | 2 + .../rollback-post_catalog_maindb_92_612.sql | 1 + .../rollback-post_catalog_otherdb_92_612.sql | 1 + .../upgrade-post_catalog_maindb_92_612.sql | 4 + .../upgrade-post_catalog_otherdb_92_612.sql | 4 + .../regress/expected/hw_replication_slots.out | 6 - src/test/regress/expected/physical_slot.out | 2 - .../expected/single_node_opr_sanity.out | 1 + .../regress/output/predefined_roles.source | 8 -- 15 files changed, 238 insertions(+), 23 deletions(-) create mode 100644 src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_92_612.sql create mode 100644 src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_92_612.sql create mode 100644 src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_612.sql create mode 100644 src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_612.sql diff --git a/src/common/backend/catalog/builtin_funcs.ini b/src/common/backend/catalog/builtin_funcs.ini index b83248bc33..6387abcc63 100755 --- a/src/common/backend/catalog/builtin_funcs.ini +++ b/src/common/backend/catalog/builtin_funcs.ini @@ -3573,6 +3573,10 @@ "gs_get_global_barriers_status", 1, AddBuiltinFunc(_0(9034), _1("gs_get_global_barriers_status"), _2(0), _3(true), _4(false), _5(gs_get_global_barriers_status), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(3, 25, 25, 25), _22(3, 'o', 'o', 'o'), _23(3, "slot_name", "global_barrier_id", "global_achive_barrier_id"), _24(NULL), _25("gs_get_global_barriers_status"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) ), + AddFuncGroup( + "gs_xlog_keepers", 1, + AddBuiltinFunc(_0(9040), _1("gs_xlog_keepers"), _2(0), _3(true), _4(false), _5(gs_xlog_keepers), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(0), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(3, 25, 25, 25), _22(3, 'o', 'o', 'o'), _23(3, "keeptype", "keepsegment", "describe"), _24(NULL), _25("gs_xlog_keepers"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f')) + ), AddFuncGroup( "gs_get_next_xid_csn", 1, AddBuiltinFunc(_0(6224), _1("gs_get_next_xid_csn"), _2(1), _3(true), _4(true), _5(gs_get_next_xid_csn), _6(2249), _7(PG_CATALOG_NAMESPACE), _8(BOOTSTRAP_SUPERUSERID), _9(INTERNALlanguageId), _10(1), _11(100), _12(0), _13(0), _14(false), _15(false), _16(false), _17(false), _18('v'), _19(0), _20(0), _21(3, 25, 28, 28), _22(3, 'o', 'o', 'o'), _23(3, "node_name", "next_xid", "next_csn"), _24(NULL), _25("gs_get_next_xid_csn"), _26(NULL), _27(NULL), _28(NULL), _29(0), _30(false), _31(NULL), _32(false), _33(NULL), _34('f'), _35(NULL), _36(0), _37(false), _38(NULL), _39(NULL), _40(0)) diff --git a/src/common/backend/utils/init/globals.cpp b/src/common/backend/utils/init/globals.cpp index e2a29b7ef2..4550d4363c 100644 --- a/src/common/backend/utils/init/globals.cpp +++ b/src/common/backend/utils/init/globals.cpp @@ -59,7 +59,7 @@ bool open_join_children = true; bool will_shutdown = false; /* hard-wired binary version number */ -const uint32 GRAND_VERSION_NUM = 92611; +const uint32 GRAND_VERSION_NUM = 92612; const uint32 SQL_PATCH_VERSION_NUM = 92608; const uint32 PREDPUSH_SAME_LEVEL_VERSION_NUM = 92522; diff --git a/src/gausskernel/storage/access/transam/xlog.cpp b/src/gausskernel/storage/access/transam/xlog.cpp index b0139bf9d4..4429c24bfd 100755 --- a/src/gausskernel/storage/access/transam/xlog.cpp +++ b/src/gausskernel/storage/access/transam/xlog.cpp @@ -349,7 +349,7 @@ static void CheckRequiredParameterValues(bool DBStateShutdown); static void XLogReportParameters(void); static void LocalSetXLogInsertAllowed(void); static void CheckPointGuts(XLogRecPtr checkPointRedo, int flags, bool doFullCheckpoint); -static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curInsert); +static XlogKeeper* KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curInsert, bool getkeeper); static XLogRecPtr XLogGetReplicationSlotMinimumLSN(void); @@ -11967,7 +11967,7 @@ void CreateCheckPoint(int flags) checkPoint.remove_seg = 1; if (_logSegNo && !GetDelayXlogRecycle()) { - KeepLogSeg(t_thrd.shemem_ptr_cxt.ControlFile->checkPointCopy.redo, &_logSegNo, curInsert); + KeepLogSeg(t_thrd.shemem_ptr_cxt.ControlFile->checkPointCopy.redo, &_logSegNo, curInsert, false); checkPoint.remove_seg = _logSegNo; _logSegNo--; /* @@ -12662,7 +12662,7 @@ bool CreateRestartPoint(int flags) endptr = GetStandbyFlushRecPtr(NULL); /* The third param is not used */ - KeepLogSeg(endptr, &_logSegNo, InvalidXLogRecPtr); + KeepLogSeg(endptr, &_logSegNo, InvalidXLogRecPtr, false); _logSegNo--; /* @@ -12886,6 +12886,84 @@ static XLogSegNo CalculateCNRecycleSegNoForStreamingHadr(XLogRecPtr curInsert, X } } +static void fill_keeper(XLogSegNo segno, int index, XlogKeeper *xlogkeeper) +{ + if(!xlogkeeper) + return; + + if(segno <= 0) + segno = 1; + xlogkeeper[index].segno = segno; + xlogkeeper[index].valid = true; +} + +static void search_archive_keeper(XlogKeeper *xlogkeeper) +{ + DIR *xldir = NULL; + struct dirent *xlde = NULL; + XLogSegNo min_ready_xlog = 0; + XLogSegNo max_done_xlog = 0; + + if(!XLogArchivingActive()) + return; + + + xldir = AllocateDir(XLOGDIR "/archive_status"); + if (xldir == NULL) { + ereport(ERROR, + (errcode_for_file_access(), + errmsg("could not open transaction log directory \"%s\"/archive_status: %m", XLOGDIR))); + } + /* + * .ready is marking wal files need to be archive and .done are ones finished archive. + * So we regard min of .ready or max of .done as one keep by archive, if no .done or + * .ready files the archive keep nothing. + */ + while ((xlde = ReadDir(xldir, XLOGDIR "/archive_status")) != NULL) { + if (strlen(xlde->d_name) > 24 && strspn(xlde->d_name, "0123456789ABCDEF") == 24) { + if (strcmp(xlde->d_name + strlen(xlde->d_name) - strlen(".ready"), ".ready") == 0) { + XLogSegNo ready_segno = 0; + TimeLineID tld = 0; + XLogFromFileName(xlde->d_name, &tld, &ready_segno); + if(0 == min_ready_xlog || min_ready_xlog > ready_segno) + min_ready_xlog = ready_segno; + } else if(strcmp(xlde->d_name + strlen(xlde->d_name) - strlen(".done"), ".done") == 0) { + XLogSegNo done_segno = 0; + TimeLineID tld = 0; + XLogFromFileName(xlde->d_name, &tld, &done_segno); + if(0 == max_done_xlog || max_done_xlog < done_segno) + max_done_xlog = done_segno; + } + } + } + FreeDir(xldir); + + if(0 == min_ready_xlog && 0 == max_done_xlog) + return; + else if(0 != max_done_xlog && 0 == min_ready_xlog) + min_ready_xlog = max_done_xlog + 1; + + fill_keeper(min_ready_xlog, WALKEEPER_ARCHIVE, xlogkeeper); +} + +XlogKeeper* generate_xlog_keepers(void) +{ + XLogSegNo logSegNoTemp = 0; + + XlogKeeper *result = NULL; + + if (RecoveryInProgress()) { + XLogRecPtr recptr = GetStandbyFlushRecPtr(NULL); + result = KeepLogSeg(recptr, &logSegNoTemp, InvalidXLogRecPtr, true); + } else { + XLogRecPtr curInsert = GetXLogWriteRecPtr(); + result = KeepLogSeg(t_thrd.shemem_ptr_cxt.ControlFile->checkPointCopy.redo, &logSegNoTemp, curInsert, true); + } + search_archive_keeper(result); + + return result; +} + /* * Retreat *logSegNo to the last segment that we need to retain because of * either wal_keep_segments or replication slots. @@ -12897,17 +12975,23 @@ static XLogSegNo CalculateCNRecycleSegNoForStreamingHadr(XLogRecPtr curInsert, X * DCF feature: Replication slot is no longer needed as consensus of XLog * is achieved in DCF. Rather than WalSnd, XLog data are replicated via DCF. */ -static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curInsert) +static XlogKeeper* KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curInsert, bool getkeeper) { XLogSegNo segno; XLogSegNo wal_keep_segno; XLogRecPtr keep; XLogRecPtr xlogcopystartptr; ReplicationSlotState repl_slot_state; + XlogKeeper *xlogkeeper = NULL; + + if(getkeeper) + xlogkeeper = (XlogKeeper*)palloc0(WALKEEPER_MAX * sizeof(XlogKeeper)); gstrace_entry(GS_TRC_ID_KeepLogSeg); XLByteToSeg(recptr, segno); + fill_keeper(segno, WALKEEPER_BASECHECK, xlogkeeper); + /* avoid underflow, don't go below 1 */ if (segno <= (uint64)(uint32)u_sess->attr.attr_storage.wal_keep_segments) { /* segno = 1 show all file should be keep */ @@ -12919,6 +13003,7 @@ static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curIns } wal_keep_segno = segno; + fill_keeper(wal_keep_segno, WALKEEPER_SEGMENT_KEEP, xlogkeeper); ReplicationSlotsComputeRequiredLSN(&repl_slot_state); keep = repl_slot_state.min_required; @@ -12938,6 +13023,7 @@ static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curIns } else if (slotSegNo < segno) { segno = slotSegNo; } + fill_keeper(segno, WALKEEPER_SLOTS, xlogkeeper); } LWLockAcquire(FullBuildXlogCopyStartPtrLock, LW_SHARED); @@ -12956,6 +13042,7 @@ static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curIns } else if (slotSegNo < segno) { segno = slotSegNo; } + fill_keeper(segno, WALKEEPER_BASEBACKUP, xlogkeeper); } load_server_mode(); @@ -12966,6 +13053,7 @@ static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curIns repl_slot_state.min_tools_required); if (mainCNSegNo < segno && mainCNSegNo > 0) { segno = mainCNSegNo; + fill_keeper(segno, WALKEEPER_COODRECYCLE, xlogkeeper); } } @@ -12983,6 +13071,7 @@ static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curIns pg_atomic_read_u32(&g_instance.comm_cxt.current_gsrewind_count) > 0) { /* segno = 1 show all file should be keep */ segno = 1; + fill_keeper(segno, WALKEEPER_BUILD, xlogkeeper); ereport(LOG, (errmsg("keep all the xlog segments, because there is a build task in the backend, " "and gs_rewind count is more than zero"))); } else if (IS_DN_MULTI_STANDYS_MODE() && !WalSndAllInProgress(SNDROLE_PRIMARY_STANDBY) && @@ -12996,9 +13085,11 @@ static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curIns segno = CalcRecycleSegNo(curInsert, repl_slot_state.quorum_min_required, repl_slot_state.min_tools_required); } + fill_keeper(segno, WALKEEPER_INVALIDSEND, xlogkeeper); } else if (IS_DN_DUMMY_STANDYS_MODE() && !WalSndInProgress(SNDROLE_PRIMARY_STANDBY)) { /* segno = 1 show all file should be keep */ segno = 1; + fill_keeper(segno, WALKEEPER_DUMMYSTANDBY, xlogkeeper); ereport(LOG, (errmsg("keep all the xlog segments, because not all the wal senders are " "in the role PRIMARY_STANDBY"))); } else { @@ -13010,6 +13101,7 @@ static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curIns archiveSlotSegNo == segno)) { segno = CalcRecycleArchiveSegNo(); g_instance.roach_cxt.isXLogForceRecycled = true; + fill_keeper(segno, WALKEEPER_RESISTARCHIVE, xlogkeeper); ereport(LOG, (errmsg("force recycle archiving xlog, because archive required xlog keep segement size " "is bigger than max keep size: %lu", maxKeepSize))); } @@ -13019,6 +13111,7 @@ static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curIns !g_instance.attr.attr_storage.dcf_attr.enable_dcf) { /* there are slots and lsn is invalid, we keep it */ segno = 1; + fill_keeper(segno, WALKEEPER_INVALIDSLOT, xlogkeeper); ereport(WARNING, (errmsg("invalid replication slot recptr"), errhint("Check slot configuration or setup standby/secondary"))); } @@ -13036,12 +13129,16 @@ static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curIns if (cbm_tracked_segno < segno && cbm_tracked_segno > 0) { segno = cbm_tracked_segno; } + if(cbm_tracked_segno > 0) + fill_keeper(cbm_tracked_segno, WALKEEPER_CBM, xlogkeeper); } if (t_thrd.xlog_cxt.server_mode != PRIMARY_MODE && t_thrd.xlog_cxt.server_mode != NORMAL_MODE) { LWLockAcquire(XlogRemoveSegLock, LW_SHARED); if (XlogRemoveSegPrimary < segno && XlogRemoveSegPrimary > 0) { segno = XlogRemoveSegPrimary; } + if(XlogRemoveSegPrimary > 0) + fill_keeper(XlogRemoveSegPrimary, WALKEEPER_CHECKPOINT, xlogkeeper); LWLockRelease(XlogRemoveSegLock); } if (t_thrd.xlog_cxt.server_mode == STANDBY_MODE && t_thrd.xlog_cxt.is_hadr_main_standby) { @@ -13055,6 +13152,8 @@ static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo, XLogRecPtr curIns *logSegNo = segno; } gstrace_exit(GS_TRC_ID_KeepLogSeg); + + return xlogkeeper; } /* diff --git a/src/gausskernel/storage/access/transam/xlogfuncs.cpp b/src/gausskernel/storage/access/transam/xlogfuncs.cpp index 696a0d5b16..c14d9d84ff 100755 --- a/src/gausskernel/storage/access/transam/xlogfuncs.cpp +++ b/src/gausskernel/storage/access/transam/xlogfuncs.cpp @@ -2612,3 +2612,82 @@ Datum gs_query_standby_cluster_barrier_id_exist(PG_FUNCTION_ARGS) } PG_RETURN_BOOL(found); } + +Datum gs_xlog_keepers(PG_FUNCTION_ARGS) +{ +#define PG_GET_XLOG_KEEPERS_COLS 3 + FuncCallContext *funcctx = NULL; + XlogKeeper *xlogkeeper = NULL; + int loop = 0; + WalKeeperPriv *privdata = NULL; + static WalKeeperDesc wkdesc[WALKEEPER_MAX] = { + {WALKEEPER_BASECHECK, "Base Keep", "base on redo lsn of recently checkpoint for primary or current working segment on standby"}, + {WALKEEPER_SEGMENT_KEEP, "Segments Keep", "base on wal_keep_segments GUC"}, + {WALKEEPER_SLOTS, "Slots Keep", "base on physical or logical slots"}, + {WALKEEPER_BASEBACKUP, "Basebackup Keep", "a basebackup operator keep all wal segments"}, + {WALKEEPER_BUILD, "Build Keep", "a build operator keep all wal segments"}, + {WALKEEPER_INVALIDSEND, "Unactived Wal Send Keep", "a wal sender unactived keep all wal segments"}, + {WALKEEPER_DUMMYSTANDBY, "Dummystandby Keep", "Dummystandby keep all wal segments"}, + {WALKEEPER_INVALIDSLOT, "Invalid Slot Keep", "an invalid slot keep all wal segments"}, + {WALKEEPER_CBM, "CBM Keep", "CBM feature keep wal segments"}, + {WALKEEPER_CHECKPOINT, "Standby Checkpoint Keep", "base on redo lsn of recently checkpoint on standby"}, + {WALKEEPER_ARCHIVE, "Archive Keep", "base on wal archive"}, + {WALKEEPER_RESISTARCHIVE, "Resist Archive", "resist OBS archive keeper due to max_size_for_xlog_prune"}, + {WALKEEPER_COODRECYCLE, "Other keep", "base on recycle xlog for Coordinator"} + }; + + if (SRF_IS_FIRSTCALL()) { + MemoryContext oldcontext = NULL; + TupleDesc resultTupleDesc = NULL; + + funcctx = SRF_FIRSTCALL_INIT(); + + oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); + resultTupleDesc = CreateTemplateTupleDesc(PG_GET_XLOG_KEEPERS_COLS, false); + TupleDescInitEntry(resultTupleDesc, (AttrNumber)1, "keeptype", TEXTOID, -1, 0); + TupleDescInitEntry(resultTupleDesc, (AttrNumber)2, "keepsegment", TEXTOID, -1, 0); + TupleDescInitEntry(resultTupleDesc, (AttrNumber)3, "describe", TEXTOID, -1, 0); + + privdata = (WalKeeperPriv*)palloc0(sizeof(WalKeeperPriv)); + privdata->keeper = generate_xlog_keepers(); + funcctx->user_fctx = (void*)privdata; + funcctx->attinmeta = TupleDescGetAttInMetadata(resultTupleDesc); + MemoryContextSwitchTo(oldcontext); + } + + funcctx = SRF_PERCALL_SETUP(); + privdata = (WalKeeperPriv*)funcctx->user_fctx; + loop = privdata->loop++; + xlogkeeper = privdata->keeper; + + while (loop < WALKEEPER_MAX) { + char **values = NULL; + char xlogFile[MAXFNAMELEN] = {0}; + + if(xlogkeeper[loop].valid) { + HeapTuple tuple = NULL; + Datum result; + + memset_s(xlogFile, MAXFNAMELEN, 0, MAXFNAMELEN); + if(1 != xlogkeeper[loop].segno) + XLogFileName(xlogFile, MAXFNAMELEN, t_thrd.shemem_ptr_cxt.ControlFile->checkPointCopy.ThisTimeLineID, xlogkeeper[loop].segno); + else { + int nRet = 0; + nRet = snprintf_s(xlogFile, MAXFNAMELEN, MAXFNAMELEN - 1, "ALL"); + securec_check_ss(nRet, "\0", "\0"); + } + values = (char**)palloc(PG_GET_XLOG_KEEPERS_COLS * sizeof(char*)); + values[0] = wkdesc[loop].keeper_name; + values[1] = xlogFile; + values[2] = wkdesc[loop].keeper_desc; + tuple = BuildTupleFromCStrings(funcctx->attinmeta, values); + + result = HeapTupleGetDatum(tuple); + SRF_RETURN_NEXT(funcctx, result); + } + loop = privdata->loop++; + } + if (xlogkeeper) + pfree(xlogkeeper); + SRF_RETURN_DONE(funcctx); +} diff --git a/src/gausskernel/storage/replication/slot.cpp b/src/gausskernel/storage/replication/slot.cpp index 966006f358..2f980f4168 100755 --- a/src/gausskernel/storage/replication/slot.cpp +++ b/src/gausskernel/storage/replication/slot.cpp @@ -1044,8 +1044,10 @@ void ReplicationSlotsComputeRequiredLSN(ReplicationSlotState *repl_slt_state) } LWLockRelease(ReplicationSlotControlLock); - XLogSetReplicationSlotMinimumLSN(min_required); - XLogSetReplicationSlotMaximumLSN(max_required); + if(InvalidXLogRecPtr != min_required) + XLogSetReplicationSlotMinimumLSN(min_required); + if(InvalidXLogRecPtr != max_required) + XLogSetReplicationSlotMaximumLSN(max_required); qsort(standby_slots_list, g_instance.attr.attr_storage.max_replication_slots, sizeof(XLogRecPtr), cmp_slot_lsn); if (repl_slt_state != NULL) { repl_slt_state->min_required = min_required; diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 3a1c44a567..923260dc2a 100755 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -628,6 +628,39 @@ struct XlogFlushStats{ TimestampTz lastRestTime; }; +typedef enum WalKeeper { + WALKEEPER_BASECHECK = 0, + WALKEEPER_SEGMENT_KEEP, + WALKEEPER_SLOTS, + WALKEEPER_BASEBACKUP, + WALKEEPER_BUILD, + WALKEEPER_INVALIDSEND, + WALKEEPER_DUMMYSTANDBY, + WALKEEPER_INVALIDSLOT, + WALKEEPER_CBM, + WALKEEPER_CHECKPOINT, + WALKEEPER_ARCHIVE, + WALKEEPER_RESISTARCHIVE, + WALKEEPER_COODRECYCLE, + WALKEEPER_MAX +} WalKeeper; + +typedef struct WalKeeperDesc { + WalKeeper keeper_id; + char *keeper_name; + char *keeper_desc; +}WalKeeperDesc; + +typedef struct XlogKeeper { + XLogSegNo segno; + bool valid; +} XlogKeeper; + +typedef struct WalKeeperPriv { + int loop; + XlogKeeper *keeper; +}WalKeeperPriv; + extern XLogSegNo GetNewestXLOGSegNo(const char* workingPath); /* * Hint bit for whether xlog contains CSN info, which is stored in xl_term. @@ -914,4 +947,5 @@ extern bool RecoveryIsSuspend(void); void TryLockSharedStorage(); extern void InitUndoCountThreshold(); +extern XlogKeeper* generate_xlog_keepers(void); #endif /* XLOG_H */ diff --git a/src/include/catalog/pg_proc.h_for_llt b/src/include/catalog/pg_proc.h_for_llt index a34bd83c47..a9f4562d6f 100755 --- a/src/include/catalog/pg_proc.h_for_llt +++ b/src/include/catalog/pg_proc.h_for_llt @@ -5778,4 +5778,6 @@ DATA(insert OID = 4463 ( byteawithoutorderwithequalcolcmpbyteal PGNSP PGUID DATA(insert OID = 4369 ( hll_hash_byteawithoutorderwithequalcol PGNSP PGUID 12 1 0 0 - f f f f t f i 1 0 4303 "4402" _null_ _null_ _null_ _null_ hll_hash_varlena _null_ _null_ _null_ "" f f f)); DESCR("hypper log log hash a byteawithoutorderwithequalcol type"); DATA(insert OID = 4449 ( byteawithoutorderwithequalcoltypmodin PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 23 "1263" _null_ _null_ _null_ _null_ byteawithoutorderwithequalcoltypmodin _null_ _null_ _null_ "" f _null_ f)); +DATA(insert OID = 9040 ( gs_xlog_keepers PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 2249 "" "{25,25,25}" "{o,o,o}" "{keeptype, keepsegment, describe}" _null_ gs_xlog_keepers _null_ _null_ _null_ "" f)); +DESCR("get xlog clean blocker"); #endif /* PG_PROC_H */ diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_92_612.sql b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_92_612.sql new file mode 100644 index 0000000000..c3a950bba2 --- /dev/null +++ b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback-post_catalog_maindb_92_612.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS pg_catalog.gs_xlog_keepers(out keeptype pg_catalog.text, out keepsegment pg_catalog.text, out describe pg_catalog.text); \ No newline at end of file diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_92_612.sql b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_92_612.sql new file mode 100644 index 0000000000..c3a950bba2 --- /dev/null +++ b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback-post_catalog_otherdb_92_612.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS pg_catalog.gs_xlog_keepers(out keeptype pg_catalog.text, out keepsegment pg_catalog.text, out describe pg_catalog.text); \ No newline at end of file diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_612.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_612.sql new file mode 100644 index 0000000000..ca6163ecad --- /dev/null +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade-post_catalog_maindb_92_612.sql @@ -0,0 +1,4 @@ +DROP FUNCTION IF EXISTS pg_catalog.gs_xlog_keepers(out keeptype pg_catalog.text, out keepsegment pg_catalog.text, out describe pg_catalog.text); +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC,9040; +CREATE OR REPLACE FUNCTION pg_catalog.gs_xlog_keepers(out keeptype pg_catalog.text, out keepsegment pg_catalog.text, out describe pg_catalog.text) +RETURNS SETOF record LANGUAGE INTERNAL VOLATILE STRICT as 'gs_xlog_keepers'; \ No newline at end of file diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_612.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_612.sql new file mode 100644 index 0000000000..ca6163ecad --- /dev/null +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade-post_catalog_otherdb_92_612.sql @@ -0,0 +1,4 @@ +DROP FUNCTION IF EXISTS pg_catalog.gs_xlog_keepers(out keeptype pg_catalog.text, out keepsegment pg_catalog.text, out describe pg_catalog.text); +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_PROC,9040; +CREATE OR REPLACE FUNCTION pg_catalog.gs_xlog_keepers(out keeptype pg_catalog.text, out keepsegment pg_catalog.text, out describe pg_catalog.text) +RETURNS SETOF record LANGUAGE INTERNAL VOLATILE STRICT as 'gs_xlog_keepers'; \ No newline at end of file diff --git a/src/test/regress/expected/hw_replication_slots.out b/src/test/regress/expected/hw_replication_slots.out index 48ec0ee400..dd50b8ca6f 100644 --- a/src/test/regress/expected/hw_replication_slots.out +++ b/src/test/regress/expected/hw_replication_slots.out @@ -33,16 +33,12 @@ select * from pg_replication_slots order by 1; (3 rows) select * from pg_drop_replication_slot('dummystandby_slot'); -WARNING: replicationSlotMinLSN is InvalidXLogRecPtr!!! -WARNING: replicationSlotMaxLSN is InvalidXLogRecPtr!!! pg_drop_replication_slot -------------------------- (1 row) select * from pg_drop_replication_slot('standby_slot'); -WARNING: replicationSlotMinLSN is InvalidXLogRecPtr!!! -WARNING: replicationSlotMaxLSN is InvalidXLogRecPtr!!! pg_drop_replication_slot -------------------------- @@ -51,8 +47,6 @@ WARNING: replicationSlotMaxLSN is InvalidXLogRecPtr!!! select * from pg_drop_replication_slot('wrong_slot_name'); ERROR: replication slot "wrong_slot_name" does not exist select * from pg_drop_replication_slot('my_physical_slot1my_physical_slot2my_physical_slot6my_physical_'); -WARNING: replicationSlotMinLSN is InvalidXLogRecPtr!!! -WARNING: replicationSlotMaxLSN is InvalidXLogRecPtr!!! pg_drop_replication_slot -------------------------- diff --git a/src/test/regress/expected/physical_slot.out b/src/test/regress/expected/physical_slot.out index b5d879d8cd..a2b7aa78a5 100644 --- a/src/test/regress/expected/physical_slot.out +++ b/src/test/regress/expected/physical_slot.out @@ -18,8 +18,6 @@ select * from pg_get_replication_slots(); (1 row) select * from pg_drop_replication_slot('test_slot'); -WARNING: replicationSlotMinLSN is InvalidXLogRecPtr!!! -WARNING: replicationSlotMaxLSN is InvalidXLogRecPtr!!! pg_drop_replication_slot -------------------------- diff --git a/src/test/regress/expected/single_node_opr_sanity.out b/src/test/regress/expected/single_node_opr_sanity.out index 178b6bc13e..c5417ee940 100755 --- a/src/test/regress/expected/single_node_opr_sanity.out +++ b/src/test/regress/expected/single_node_opr_sanity.out @@ -1558,6 +1558,7 @@ WHERE d.classoid IS NULL AND p1.oid <= 9999 order by 1; 9031 | gs_set_obs_delete_location 9032 | gs_get_global_barrier_status 9033 | gs_get_local_barrier_status + 9040 | gs_xlog_keepers 9034 | gs_get_global_barriers_status 9035 | gs_set_obs_delete_location_with_slotname 9037 | gs_set_standby_cluster_target_barrier_id diff --git a/src/test/regress/output/predefined_roles.source b/src/test/regress/output/predefined_roles.source index 085023c6e9..eab4dd4bbe 100755 --- a/src/test/regress/output/predefined_roles.source +++ b/src/test/regress/output/predefined_roles.source @@ -295,20 +295,12 @@ SELECT pg_logical_slot_peek_binary_changes('privs_test_slot', NULL, NULL, 'force (0 rows) SELECT pg_drop_replication_slot('privs_test_slot'); -WARNING: replicationSlotMinLSN is InvalidXLogRecPtr!!! -CONTEXT: referenced column: pg_drop_replication_slot -WARNING: replicationSlotMaxLSN is InvalidXLogRecPtr!!! -CONTEXT: referenced column: pg_drop_replication_slot pg_drop_replication_slot -------------------------- (1 row) SELECT pg_drop_replication_slot('privs_test_physlot'); -WARNING: replicationSlotMinLSN is InvalidXLogRecPtr!!! -CONTEXT: referenced column: pg_drop_replication_slot -WARNING: replicationSlotMaxLSN is InvalidXLogRecPtr!!! -CONTEXT: referenced column: pg_drop_replication_slot pg_drop_replication_slot -------------------------- -- Gitee