diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index 73004fe7b722d2fd2c15930f69a38d78aca4220d..5ac0e39dcc134260945d5328ac8035559574f277 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -270,3 +270,9 @@ # in retrieve blocking model, only in 50% query threads will be used in query processing in dnode # retrieveBlockingModel 0 + +# the maximum allowed query buffer size in MB during query processing for each data node +# -1 no limit (default) +# 0 no query allowed, queries are disabled +# queryBufferSize -1 + diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 284e71801603e8184f14e96bb42b4d1896060780..9b498e8bd2ab9e8bf2f31f5a91e6d881544a34f9 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -57,7 +57,8 @@ extern int32_t tsCompressMsgSize; extern char tsTempDir[]; //query buffer management -extern int32_t tsQueryBufferSize; // maximum allowed usage buffer for each data node during query processing +extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing +extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node during query processing extern int32_t tsRetrieveBlockingModel;// retrieve threads will be blocked extern int8_t tsKeepOriginalColumnName; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 4a9b4c3e4357679e034fbda8ae296ed7b3589483..a2d02be683cd9b78e518d9630d604d8874035d68 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -105,6 +105,7 @@ int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance // 0 no query allowed, queries are disabled // positive value (in MB) int32_t tsQueryBufferSize = -1; +int64_t tsQueryBufferSizeBytes = -1; // in retrieve blocking model, the retrieve threads will wait for the completion of the query processing. int32_t tsRetrieveBlockingModel = 0; @@ -283,7 +284,7 @@ bool taosCfgDynamicOptions(char *msg) { int32_t cfgLen = (int32_t)strlen(cfg->option); if (cfgLen != olen) continue; if (strncasecmp(option, cfg->option, olen) != 0) continue; - if (cfg->valType != TAOS_CFG_VTYPE_INT32) { + if (cfg->valType == TAOS_CFG_VTYPE_INT32) { *((int32_t *)cfg->ptr) = vint; } else { *((int8_t *)cfg->ptr) = (int8_t)vint; @@ -1488,6 +1489,10 @@ int32_t taosCheckGlobalCfg() { tsSyncPort = tsServerPort + TSDB_PORT_SYNC; tsHttpPort = tsServerPort + TSDB_PORT_HTTP; + if (tsQueryBufferSize >= 0) { + tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL; + } + taosPrintGlobalCfg(); return 0; diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 6e1945407cc0e7682a884a99ea0095bdc27c7b2c..38ba6b54008bc91c83b6a3be9b74ad287b52604c 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -7730,15 +7730,15 @@ static int64_t getQuerySupportBufSize(size_t numOfTables) { int32_t checkForQueryBuf(size_t numOfTables) { int64_t t = getQuerySupportBufSize(numOfTables); - if (tsQueryBufferSize < 0) { + if (tsQueryBufferSizeBytes < 0) { return TSDB_CODE_SUCCESS; - } else if (tsQueryBufferSize > 0) { + } else if (tsQueryBufferSizeBytes > 0) { while(1) { - int64_t s = tsQueryBufferSize; + int64_t s = tsQueryBufferSizeBytes; int64_t remain = s - t; if (remain >= 0) { - if (atomic_val_compare_exchange_64(&tsQueryBufferSize, s, remain) == s) { + if (atomic_val_compare_exchange_64(&tsQueryBufferSizeBytes, s, remain) == s) { return TSDB_CODE_SUCCESS; } } else { @@ -7752,14 +7752,14 @@ int32_t checkForQueryBuf(size_t numOfTables) { } void releaseQueryBuf(size_t numOfTables) { - if (tsQueryBufferSize <= 0) { + if (tsQueryBufferSizeBytes < 0) { return; } int64_t t = getQuerySupportBufSize(numOfTables); // restore value is not enough buffer available - atomic_add_fetch_64(&tsQueryBufferSize, t); + atomic_add_fetch_64(&tsQueryBufferSizeBytes, t); } void* qGetResultRetrieveMsg(qinfo_t qinfo) {