From 26778f29da330f4c9152227003a105b95650a601 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 1 Nov 2022 10:42:13 +0800 Subject: [PATCH 1/3] enh: add config for persist wal at the beginning of vnodeCommit --- include/common/tglobal.h | 3 +++ include/libs/wal/wal.h | 1 - source/common/src/tglobal.c | 3 +++ source/libs/wal/src/walMeta.c | 6 +++--- source/libs/wal/src/walWrite.c | 3 ++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/common/tglobal.h b/include/common/tglobal.h index cb4426f8a9..f277eea219 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -125,6 +125,9 @@ extern char tsSmlChildTableName[]; extern char tsSmlTagName[]; extern bool tsSmlDataFormat; +// wal +extern int64_t tsWalRecoverSizeLimit; + // internal extern int32_t tsTransPullupInterval; extern int32_t tsMqRebalanceInterval; diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index 8f936f988b..ed85fd3517 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -43,7 +43,6 @@ extern "C" { #define WAL_FILE_LEN (WAL_PATH_LEN + 32) #define WAL_MAGIC 0xFAFBFCFDF4F3F2F1ULL #define WAL_SCAN_BUF_SIZE (1024 * 1024 * 3) -#define WAL_RECOV_SIZE_LIMIT (200 * WAL_SCAN_BUF_SIZE) typedef enum { TAOS_WAL_WRITE = 1, diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index fbb9e04a25..97c54390c0 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -156,6 +156,9 @@ char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPR // udf bool tsStartUdfd = true; +// wal +int64_t tsWalRecoverSizeLimit = (600 * 1024 * 1024L); + // internal int32_t tsTransPullupInterval = 2; int32_t tsMqRebalanceInterval = 2; diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index bcc9a11458..e9b615b300 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -18,6 +18,7 @@ #include "taoserror.h" #include "tutil.h" #include "walInt.h" +#include "tglobal.h" bool FORCE_INLINE walLogExist(SWal* pWal, int64_t ver) { return !walIsEmpty(pWal) && walGetFirstVer(pWal) <= ver && walGetLastVer(pWal) >= ver; @@ -82,11 +83,10 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) { readSize = end - offset; capacity = readSize + sizeof(magic); - int64_t limit = WAL_RECOV_SIZE_LIMIT; - if (limit < readSize) { + if (tsWalRecoverSizeLimit < readSize) { wError("vgId:%d, possibly corrupted WAL range exceeds size limit (i.e. %" PRId64 " bytes). offset:%" PRId64 ", end:%" PRId64 ", file:%s", - pWal->cfg.vgId, limit, offset, end, fnameStr); + pWal->cfg.vgId, tsWalRecoverSizeLimit, offset, end, fnameStr); terrno = TSDB_CODE_WAL_SIZE_LIMIT; goto _err; } diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index 7f4fbb7c71..005450a267 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -16,6 +16,7 @@ #include "os.h" #include "taoserror.h" #include "tchecksum.h" +#include "tglobal.h" #include "walInt.h" int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) { @@ -252,7 +253,7 @@ static FORCE_INLINE int32_t walCheckAndRoll(SWal *pWal) { } } - if (walGetLastFileCachedSize(pWal) > WAL_RECOV_SIZE_LIMIT / 2) { + if (walGetLastFileCachedSize(pWal) > tsWalRecoverSizeLimit / 2) { if (walSaveMeta(pWal) < 0) { return -1; } From a2d11e0fdb7200448aa7333ca62df63f997ca8b1 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 1 Nov 2022 11:27:28 +0800 Subject: [PATCH 2/3] enh: add config for persist wal at the beginning of vnodeCommit --- source/common/src/tglobal.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 97c54390c0..b76e9f6d67 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -425,6 +425,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "uptimeInterval", tsUptimeInterval, 1, 100000, 1) != 0) return -1; if (cfgAddInt32(pCfg, "queryRsmaTolerance", tsQueryRsmaTolerance, 0, 900000, 0) != 0) return -1; + if (cfgAddInt64(pCfg, "walRecoverSizeLimit", tsWalRecoverSizeLimit, 3*1024*1024, INT64_MAX, 0) != 0) return -1; + if (cfgAddBool(pCfg, "udf", tsStartUdfd, 0) != 0) return -1; if (cfgAddString(pCfg, "udfdResFuncs", tsUdfdResFuncs, 0) != 0) return -1; GRANT_CFG_ADD; @@ -723,6 +725,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsUptimeInterval = cfgGetItem(pCfg, "uptimeInterval")->i32; tsQueryRsmaTolerance = cfgGetItem(pCfg, "queryRsmaTolerance")->i32; + tsWalRecoverSizeLimit = cfgGetItem(pCfg, "walRecoverSizeLimit")->i32; + tsStartUdfd = cfgGetItem(pCfg, "udf")->bval; tstrncpy(tsUdfdResFuncs, cfgGetItem(pCfg, "udfdResFuncs")->str, sizeof(tsUdfdResFuncs)); From 2990a127cb3293fb4c8574b46e319db4368a24ae Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 1 Nov 2022 11:29:02 +0800 Subject: [PATCH 3/3] enh: add config for persist wal at the beginning of vnodeCommit --- source/common/src/tglobal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index b76e9f6d67..0d45454731 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -725,7 +725,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsUptimeInterval = cfgGetItem(pCfg, "uptimeInterval")->i32; tsQueryRsmaTolerance = cfgGetItem(pCfg, "queryRsmaTolerance")->i32; - tsWalRecoverSizeLimit = cfgGetItem(pCfg, "walRecoverSizeLimit")->i32; + tsWalRecoverSizeLimit = cfgGetItem(pCfg, "walRecoverSizeLimit")->i64; tsStartUdfd = cfgGetItem(pCfg, "udf")->bval; tstrncpy(tsUdfdResFuncs, cfgGetItem(pCfg, "udfdResFuncs")->str, sizeof(tsUdfdResFuncs));