From a2459fae311660c6050834bdb17f718ea3881c28 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 29 Sep 2021 10:33:17 +0800 Subject: [PATCH] add walFlushSize --- src/common/inc/tglobal.h | 5 +++-- src/common/src/tglobal.c | 14 +++++++++++++- src/inc/taosdef.h | 4 ++++ src/util/inc/tconfig.h | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index beeb4e8b24..7535fd8563 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -108,8 +108,9 @@ extern int32_t tsQuorum; extern int8_t tsUpdate; extern int8_t tsCacheLastRow; -//tsdb -extern bool tsdbForceKeepFile; +//tsdb +extern bool tsdbForceKeepFile; +extern int32_t tsdbWalFlushSize; // balance extern int8_t tsEnableBalance; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 7d352a9dc1..8fc05fe465 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -155,7 +155,8 @@ int32_t tsTsdbMetaCompactRatio = TSDB_META_COMPACT_RATIO; // tsdb config // For backward compatibility -bool tsdbForceKeepFile = false; +bool tsdbForceKeepFile = false; +int32_t tsdbWalFlushSize = TSDB_DEFAULT_WAL_FLUSH_SIZE; // [0,10000000] MB // balance int8_t tsEnableBalance = 1; @@ -1651,6 +1652,17 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + // flush vnode wal file if walSize >= walFlushSize and walSize >= cache*blocks*0.5 + cfg.option = "walFlushSize"; + cfg.ptr = &tsdbWalFlushSize; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT; + cfg.minValue = TSDB_MIN_WAL_FLUSH_SIZE; + cfg.maxValue = TSDB_MAX_WAL_FLUSH_SIZE; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_MB; + taosInitConfigOption(cfg); + #ifdef TD_TSZ // lossy compress cfg.option = "lossyColumns"; diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index d80caad88d..6e9782fbd1 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -278,6 +278,10 @@ do { \ #define TSDB_MAX_TOTAL_BLOCKS 10000 #define TSDB_DEFAULT_TOTAL_BLOCKS 6 +#define TSDB_MIN_WAL_FLUSH_SIZE 0 +#define TSDB_MAX_WAL_FLUSH_SIZE 10000000 +#define TSDB_DEFAULT_WAL_FLUSH_SIZE 1024 // 1024MB + #define TSDB_MIN_TABLES 4 #define TSDB_MAX_TABLES 10000000 #define TSDB_DEFAULT_TABLES 1000000 diff --git a/src/util/inc/tconfig.h b/src/util/inc/tconfig.h index 2ba4b964c0..3ba0031a07 100644 --- a/src/util/inc/tconfig.h +++ b/src/util/inc/tconfig.h @@ -20,7 +20,7 @@ extern "C" { #endif -#define TSDB_CFG_MAX_NUM 124 +#define TSDB_CFG_MAX_NUM 125 #define TSDB_CFG_PRINT_LEN 23 #define TSDB_CFG_OPTION_LEN 24 #define TSDB_CFG_VALUE_LEN 41 -- GitLab