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..43b63de935caf5172b4d5e91f4648a458bc653ec 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 * 1048576; + } + taosPrintGlobalCfg(); return 0; diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 6e1945407cc0e7682a884a99ea0095bdc27c7b2c..f13e9ef62359d66993f50d21f986fba19fc80e3a 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) { @@ -7915,3 +7915,4 @@ void** qReleaseQInfo(void* pMgmt, void* pQInfo, bool freeHandle) { taosCacheRelease(pQueryMgmt->qinfoPool, pQInfo, freeHandle); return 0; } + \ No newline at end of file