diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 004508de27fc9d1cf1cd97e1784d90c01b10956b..1f139ea2a5ad5c3d847a22e59c9c32a57198207b 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -777,6 +777,13 @@ void tscRetrieveFromVnodeCallBack(void *param, TAOS_RES *tres, int numOfRows) { tscGetSrcColumnInfo(colInfo, &pPObj->cmd); tColModelDisplayEx(pDesc->pSchema, pRes->data, pRes->numOfRows, pRes->numOfRows, colInfo); #endif + if (tsAvailTmpDirGB < tsMinimalTmpDirGB) { + tscError("%p sub:%p client disk space remain %.3f GB, need at least %.3f GB, stop query", + pPObj, pSql, tsAvailTmpDirGB, tsMinimalTmpDirGB); + tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_CLI_NO_DISKSPACE); + return; + } + int32_t ret = saveToBuffer(trsupport->pExtMemBuffer[idx - 1], pDesc, trsupport->localBuffer, pRes->data, pRes->numOfRows, pCmd->groupbyExpr.orderType); if (ret < 0) { @@ -802,6 +809,12 @@ void tscRetrieveFromVnodeCallBack(void *param, TAOS_RES *tres, int numOfRows) { tColModelDisplayEx(pDesc->pSchema, trsupport->localBuffer->data, trsupport->localBuffer->numOfElems, trsupport->localBuffer->numOfElems, colInfo); #endif + if (tsAvailTmpDirGB < tsMinimalTmpDirGB) { + tscError("%p sub:%p client disk space remain %.3f GB, need at least %.3f GB, stop query", + pPObj, pSql, tsAvailTmpDirGB, tsMinimalTmpDirGB); + tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_CLI_NO_DISKSPACE); + return; + } // each result for a vnode is ordered as an independant list, // then used as an input of loser tree for disk-based merge routine diff --git a/src/inc/tglobalcfg.h b/src/inc/tglobalcfg.h index 4d52b1614227c33b8f8ef197c96dd99b9bd953f4..43bdce942c2debc917156ab9c546afb4c0e3cacf 100644 --- a/src/inc/tglobalcfg.h +++ b/src/inc/tglobalcfg.h @@ -29,10 +29,15 @@ extern int64_t tsPageSize; extern int64_t tsOpenMax; extern int64_t tsStreamMax; extern int32_t tsNumOfCores; -extern int32_t tsTotalDiskGB; -extern float tsDiskAvailGB; -extern float tsDiskUsedGB; -extern float tsDiskMinimalGB; +extern float tsTotalLogDirGB; +extern float tsTotalTmpDirGB; +extern float tsTotalDataDirGB; +extern float tsAvailLogDirGB; +extern float tsAvailTmpDirGB; +extern float tsAvailDataDirGB; +extern float tsMinimalLogDirGB; +extern float tsMinimalTmpDirGB; +extern float tsMinimalDataDirGB; extern int32_t tsTotalMemoryMB; extern int32_t tsVersion; diff --git a/src/modules/monitor/src/monitorSystem.c b/src/modules/monitor/src/monitorSystem.c index 082cfb2e53ed1662b3576275fc134c3a3356a029..4571423725696bf0dc4c7de30edb213040c56c78 100644 --- a/src/modules/monitor/src/monitorSystem.c +++ b/src/modules/monitor/src/monitorSystem.c @@ -273,7 +273,7 @@ int monitorBuildCpuSql(char *sql) { // unit is GB int monitorBuildDiskSql(char *sql) { - return sprintf(sql, ", %f, %d", tsDiskUsedGB, tsTotalDiskGB); + return sprintf(sql, ", %f, %d", (tsTotalDataDirGB - tsAvailDataDirGB), (int32_t)tsTotalDataDirGB); } // unit is Kb diff --git a/src/system/src/mgmtSystem.c b/src/system/src/mgmtSystem.c index 018300bf61d7fe767739ffa86481a53a97128bb1..0aed50229ee1d57215d0c5bead48846150b44015 100644 --- a/src/system/src/mgmtSystem.c +++ b/src/system/src/mgmtSystem.c @@ -64,7 +64,7 @@ void mgmtProcessDnodeStatus(void *handle, void *tmrId) { float memoryUsedMB = 0; taosGetSysMemory(&memoryUsedMB); pObj->memoryAvailable = tsTotalMemoryMB - memoryUsedMB; - pObj->diskAvailable = tsDiskAvailGB; + pObj->diskAvailable = tsAvailDataDirGB; for (int vnode = 0; vnode < pObj->numOfVnodes; ++vnode) { SVnodeLoad *pVload = &(pObj->vload[vnode]); diff --git a/src/system/src/vnodeQueryImpl.c b/src/system/src/vnodeQueryImpl.c index c958754298f29d9bce86851b13e0957f87f78177..29e1d4c3c4214dc1bf3eb4a1467e2928b4fde5d6 100644 --- a/src/system/src/vnodeQueryImpl.c +++ b/src/system/src/vnodeQueryImpl.c @@ -2656,7 +2656,7 @@ static void vnodeOpenAllFiles(SQInfo *pQInfo, int32_t vnodeId) { int32_t firstFid = pVnode->fileId - pVnode->numOfFiles + 1; if (fid > pVnode->fileId || fid < firstFid) { - dError("QInfo:%p error data file:%s in vid:%d, fid:%d, fid range:%d-%d", pQInfo, pEntry->d_name, vnodeId, + dError("QInfo:%p error data file:%s in vid:%d, fid:%d, fid range:%d-%d", pQInfo, pEntry->d_name, vnodeId, fid, firstFid, pVnode->fileId); continue; } diff --git a/src/system/src/vnodeShell.c b/src/system/src/vnodeShell.c index 27757d8a5cbef07123abc2f67a66a03b74bdb2e1..c4aece259ebf83bddd6d31f2a7736b1b9d060efc 100644 --- a/src/system/src/vnodeShell.c +++ b/src/system/src/vnodeShell.c @@ -471,8 +471,8 @@ int vnodeProcessShellSubmitRequest(char *pMsg, int msgLen, SShellObj *pObj) { goto _submit_over; } - if (tsDiskAvailGB < tsDiskMinimalGB) { - dError("server disk space remain %.3f GB, need at least %.2f GB, stop writing", tsDiskAvailGB, tsDiskMinimalGB); + if (tsAvailDataDirGB < tsMinimalDataDirGB) { + dError("server disk space remain %.3f GB, need at least %.3f GB, stop writing", tsAvailDataDirGB, tsMinimalDataDirGB); code = TSDB_CODE_SERVER_NO_SPACE; goto _submit_over; } diff --git a/src/util/src/tglobalcfg.c b/src/util/src/tglobalcfg.c index f9a9e2666a0beb6c84cf919c408c7baee60f99e0..af08e55c80442a8ddc7bd0965ef16f5b0e8f6a8d 100644 --- a/src/util/src/tglobalcfg.c +++ b/src/util/src/tglobalcfg.c @@ -34,10 +34,15 @@ int64_t tsPageSize; int64_t tsOpenMax; int64_t tsStreamMax; int32_t tsNumOfCores = 1; -int32_t tsTotalDiskGB = 0; -float tsDiskAvailGB = 0; -float tsDiskUsedGB = 0; -float tsDiskMinimalGB = 0.5; +float tsTotalLogDirGB = 0; +float tsTotalTmpDirGB = 0; +float tsTotalDataDirGB = 0; +float tsAvailLogDirGB = 0; +float tsAvailTmpDirGB = 0; +float tsAvailDataDirGB = 0; +float tsMinimalLogDirGB = 0.1; +float tsMinimalTmpDirGB = 0.1; +float tsMinimalDataDirGB = 0.5; int32_t tsTotalMemoryMB = 0; int32_t tsVersion = 0; @@ -507,6 +512,13 @@ void tsInitGlobalConfig() { tsInitConfigOption(cfg++, "maxVnodeConnections", &tsMaxVnodeConnections, TSDB_CFG_VTYPE_INT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 10, 50000000, 0, TSDB_CFG_UTYPE_NONE); + tsInitConfigOption(cfg++, "minimalLogDirGB", &tsMinimalLogDirGB, TSDB_CFG_VTYPE_FLOAT, + TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 0.001, 10000000, 0, TSDB_CFG_UTYPE_GB); + tsInitConfigOption(cfg++, "minimalTmpDirGB", &tsMinimalTmpDirGB, TSDB_CFG_VTYPE_FLOAT, + TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 0.001, 10000000, 0, TSDB_CFG_UTYPE_GB); + tsInitConfigOption(cfg++, "minimalDataDirGB", &tsMinimalDataDirGB, TSDB_CFG_VTYPE_FLOAT, + TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 0.001, 10000000, 0, TSDB_CFG_UTYPE_GB); + // module configs tsInitConfigOption(cfg++, "enableHttp", &tsEnableHttpModule, TSDB_CFG_VTYPE_INT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 0, 1, 1, TSDB_CFG_UTYPE_NONE); diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c index c19f844c1eb34b17358c1cafb1561e9cdccccd03..6807da07e8faae7ffacb5c99fe52decf28364464 100644 --- a/src/util/src/tlog.c +++ b/src/util/src/tlog.c @@ -323,8 +323,10 @@ char *tprefix(char *prefix) { } void tprintf(const char *const flags, int dflag, const char *const format, ...) { - if (tsTotalDiskGB != 0 && tsDiskAvailGB < (tsDiskMinimalGB/2)) { - printf("server disk space remain %.3f GB, stop write log\n", tsDiskAvailGB); + if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < (tsMinimalLogDirGB / 2)) { + printf("server disk space remain %.3f GB, stop write log\n", tsAvailLogDirGB); + fflush(stdout); + return; } va_list argpointer; @@ -373,8 +375,9 @@ void tprintf(const char *const flags, int dflag, const char *const format, ...) } void taosDumpData(unsigned char *msg, int len) { - if (tsTotalDiskGB != 0 && tsDiskAvailGB < (tsDiskMinimalGB/2)) { - printf("server disk space remain %.3f GB, stop write log\n", tsDiskAvailGB); + if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < (tsMinimalLogDirGB / 2)) { + printf("server disk space remain %.3f GB, stop write log\n", tsAvailLogDirGB); + fflush(stdout); return; } @@ -401,8 +404,9 @@ void taosDumpData(unsigned char *msg, int len) { } void taosPrintLongString(const char *const flags, int dflag, const char *const format, ...) { - if (tsTotalDiskGB != 0 && tsDiskAvailGB < (tsDiskMinimalGB/2)) { - printf("server disk space remain %.3f GB, stop write log\n", tsDiskAvailGB); + if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < (tsMinimalLogDirGB / 2)) { + printf("server disk space remain %.3f GB, stop write log\n", tsAvailLogDirGB); + fflush(stdout); return; } diff --git a/src/util/src/tsystem.c b/src/util/src/tsystem.c index 1309d532d43451da52e9044e0198d7a6d8dbd84c..7860a2152dbb2fc209b65e15b79c613dc0a0fd31 100644 --- a/src/util/src/tsystem.c +++ b/src/util/src/tsystem.c @@ -326,15 +326,29 @@ bool taosGetDisk() { struct statvfs info; const double unit = 1024 * 1024 * 1024; - if (statvfs(tsDirectory, &info)) { - tsDiskUsedGB = 0; - tsTotalDiskGB = 0; + if (statvfs(dataDir, &info)) { + tsTotalDataDirGB = 0; + tsAvailDataDirGB = 0; return false; + } else { + tsTotalDataDirGB = (float)((double)info.f_blocks * (double)info.f_frsize / unit); + tsAvailDataDirGB = (float)((double)info.f_bavail * (double)info.f_frsize / unit); + } + + if (statvfs(logDir, &info)) { + tsAvailLogDirGB = 0; + return false; + } else { tsTotalLogDirGB = (float)((double)info.f_blocks * (double)info.f_frsize / unit); + tsAvailLogDirGB = (float)((double)info.f_bavail * (double)info.f_frsize / unit); } - tsDiskAvailGB = (float)((double)info.f_bavail * (double)info.f_frsize / unit); - tsTotalDiskGB = (int32_t)((double)info.f_blocks * (double)info.f_frsize / unit); - tsDiskUsedGB = (float)tsTotalDiskGB - tsDiskAvailGB; + if (statvfs("/tmp", &info)) { + tsAvailTmpDirGB = 0; + return false; + } else { + tsTotalTmpDirGB = (float)((double)info.f_blocks * (double)info.f_frsize / unit); + tsAvailTmpDirGB = (float)((double)info.f_bavail * (double)info.f_frsize / unit); + } return true; } @@ -563,7 +577,7 @@ void tsPrintOsInfo() { pPrint(" os openMax: %ld", tsOpenMax); pPrint(" os streamMax: %ld", tsStreamMax); pPrint(" os numOfCores: %d", tsNumOfCores); - pPrint(" os totalDisk: %d(GB)", tsTotalDiskGB); + pPrint(" os totalDisk: %f(GB)", tsTotalDataDirGB); pPrint(" os totalMemory: %d(MB)", tsTotalMemoryMB); struct utsname buf;