diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index beeb4e8b243e21e33f4162b07ec218c40e4029f9..7535fd8563a79f021ca2e958e2b70b135d1d038f 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 7d352a9dc1f0a9a97c7c1920f898fb286a01497f..8fc05fe465e7604a11b4710abf0c2cf6cfe57e52 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 d80caad88db865d83986e4c19d95603eadde9884..6e9782fbd1f5b0923196647b4f06c0dfd201dfff 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 2ba4b964c04b0a1ca9f883cd619aae2b7fcbe1d7..3ba0031a07a83d7374b3f940cf51bf31478cfd38 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