diff --git a/src/bin/gs_guc/cluster_guc.conf b/src/bin/gs_guc/cluster_guc.conf index e5e2ca0eb3037b76863d8838f84fd03024080c0f..c3feaff297a66fc5cf7a533c9abe75c9de664a1b 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 8cbd43d24f81d4d7b5b861c280f0f777d132a556..6a9afc4c18af231ac0cfbbbde7d78a96ebcb440a 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 b3387d5b88414a6756cb1693490cd1ef583ba448..0261a46d936e4cf00a5d866eb547ad44a0aad448 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 f8bf08d42b40c905f2ceeffd2d322d0b61b82c28..cdc2e6c0829e0ac3974014ff3969cdd6228dc98f 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 741a31089edd8aec6280cdb62f3764db961cb774..32909be369fc37f43212d17d68e0e75296467b97 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_ */