From 5d0e0aebae96a468544cd8b597826c1248bdeeea Mon Sep 17 00:00:00 2001 From: sovyyvos Date: Thu, 20 Mar 2025 17:13:09 +0800 Subject: [PATCH] add htap wait xlog lsn timeout parameter --- src/bin/gs_guc/cluster_guc.conf | 1 + .../backend/utils/misc/guc/guc_storage.cpp | 16 ++++++++++++++++ src/gausskernel/storage/htap/imcs_ctlg.cpp | 9 +++++++-- src/include/access/htap/imcs_ctlg.h | 1 - .../knl/knl_guc/knl_instance_attr_storage.h | 4 ++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/bin/gs_guc/cluster_guc.conf b/src/bin/gs_guc/cluster_guc.conf index e5e2ca0eb3..c3feaff297 100755 --- a/src/bin/gs_guc/cluster_guc.conf +++ b/src/bin/gs_guc/cluster_guc.conf @@ -25,6 +25,7 @@ max_imcs_cache|int|102400,2147483647|kB|NULL| enable_parallel_populate|bool|0,0|NULL|NULL| enable_imcsscan|bool|0,0|NULL|NULL| +htap_wait_xlog_lsn_timeout|int|0,2147483|s|NULL| enable_borrow_memory|bool|0,0|NULL|NULL| max_borrow_memory|int|0,2147483647|kB|NULL| borrow_work_mem|int|0,2147483647|kB|This option is an extension of work_mem. For complex queries, each operator can use the amount of remote memory that this parameter is declared. The maximum expected remote memory usage is multiplied by the number of operators multiplied by the number of concurrency. | diff --git a/src/common/backend/utils/misc/guc/guc_storage.cpp b/src/common/backend/utils/misc/guc/guc_storage.cpp index 8cbd43d24f..6a9afc4c18 100755 --- a/src/common/backend/utils/misc/guc/guc_storage.cpp +++ b/src/common/backend/utils/misc/guc/guc_storage.cpp @@ -4190,6 +4190,22 @@ static void InitStorageConfigureNamesInt() NULL, NULL, NULL}, +#ifdef ENABLE_HTAP + {{"htap_wait_xlog_lsn_timeout", + PGC_POSTMASTER, + NODE_ALL, + REPLICATION_STANDBY, + gettext_noop("Sets the timeout for standby to wait xlog redo to latest lsn."), + NULL, + GUC_UNIT_S}, + &g_instance.attr.attr_storage.htap_wait_xlog_lsn_timeout, + 60, + 0, + INT_MAX / 1000, + NULL, + NULL, + NULL}, +#endif /* End-of-list marker */ {{NULL, (GucContext)0, diff --git a/src/gausskernel/storage/htap/imcs_ctlg.cpp b/src/gausskernel/storage/htap/imcs_ctlg.cpp index b3387d5b88..0261a46d93 100644 --- a/src/gausskernel/storage/htap/imcs_ctlg.cpp +++ b/src/gausskernel/storage/htap/imcs_ctlg.cpp @@ -1054,6 +1054,9 @@ static int HandleImcsResponse(PGXCNodeHandle *conn, RemoteQueryState *combiner) return RESPONSE_PLANID_OK; case 'E': /* Populate error */ return RESPONSE_EOF; + case 'n': /* Wait LSN timeout */ + elog(WARNING, "Standby wait xlog redo lsn timeout, please set a larger timeout, current " + "htap_wait_xlog_lsn_timeout = %ds", g_instance.attr.attr_storage.htap_wait_xlog_lsn_timeout); case 'I': /* EmptyQuery */ default: /* sync lost? */ @@ -1369,9 +1372,11 @@ void WaitXLogRedoToCurrentLsn(XLogRecPtr currentLsn) break; } - if (waitTimeMs >= WAIT_XLOG_REDO_TIMEOUT_MS) { + if ((waitTimeMs / MSECS_PER_SEC) >= g_instance.attr.attr_storage.htap_wait_xlog_lsn_timeout) { + pq_putemptymessage('n'); + pq_flush(); ereport(ERROR, (errmsg("Wait lsn for HTAP population time out after %fs, current lsn: %lu," - "xlog redo lsn: %lu.", ((double)waitTimeMs / 1000), currentLsn, latestXLogLsn))); + "xlog redo lsn: %lu.", ((double)waitTimeMs / MSECS_PER_SEC), currentLsn, latestXLogLsn))); } pg_usleep(100000); /* sleep 100ms */ diff --git a/src/include/access/htap/imcs_ctlg.h b/src/include/access/htap/imcs_ctlg.h index f8bf08d42b..cdc2e6c082 100644 --- a/src/include/access/htap/imcs_ctlg.h +++ b/src/include/access/htap/imcs_ctlg.h @@ -43,7 +43,6 @@ #define CHECK_WALRCV_FREQ 1024 #define WALRCV_STATUS_UP 0 #define WALRCV_STATUS_DOWN 1 -#define WAIT_XLOG_REDO_TIMEOUT_MS 60000 #define IMCSTORE_CACHE_UP 0 #define IMCSTORE_CACHE_DOWN 1 #define CHECK_IMCSTORE_CACHE_DOWN \ diff --git a/src/include/knl/knl_guc/knl_instance_attr_storage.h b/src/include/knl/knl_guc/knl_instance_attr_storage.h index 741a31089e..32909be369 100755 --- a/src/include/knl/knl_guc/knl_instance_attr_storage.h +++ b/src/include/knl/knl_guc/knl_instance_attr_storage.h @@ -260,6 +260,10 @@ typedef struct knl_instance_attr_storage { int parallel_recovery_dispatch_algorithm; bool enable_tpc_fragment_chunks; + +#ifdef ENABLE_HTAP + int htap_wait_xlog_lsn_timeout; +#endif } knl_instance_attr_storage; #endif /* SRC_INCLUDE_KNL_KNL_INSTANCE_ATTR_STORAGE_H_ */ -- Gitee