提交 89b72283 编写于 作者: S slguan

fix the issue #404

上级 20c9577e
...@@ -777,6 +777,13 @@ void tscRetrieveFromVnodeCallBack(void *param, TAOS_RES *tres, int numOfRows) { ...@@ -777,6 +777,13 @@ void tscRetrieveFromVnodeCallBack(void *param, TAOS_RES *tres, int numOfRows) {
tscGetSrcColumnInfo(colInfo, &pPObj->cmd); tscGetSrcColumnInfo(colInfo, &pPObj->cmd);
tColModelDisplayEx(pDesc->pSchema, pRes->data, pRes->numOfRows, pRes->numOfRows, colInfo); tColModelDisplayEx(pDesc->pSchema, pRes->data, pRes->numOfRows, pRes->numOfRows, colInfo);
#endif #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, int32_t ret = saveToBuffer(trsupport->pExtMemBuffer[idx - 1], pDesc, trsupport->localBuffer, pRes->data,
pRes->numOfRows, pCmd->groupbyExpr.orderType); pRes->numOfRows, pCmd->groupbyExpr.orderType);
if (ret < 0) { if (ret < 0) {
...@@ -802,6 +809,12 @@ void tscRetrieveFromVnodeCallBack(void *param, TAOS_RES *tres, int numOfRows) { ...@@ -802,6 +809,12 @@ void tscRetrieveFromVnodeCallBack(void *param, TAOS_RES *tres, int numOfRows) {
tColModelDisplayEx(pDesc->pSchema, trsupport->localBuffer->data, trsupport->localBuffer->numOfElems, tColModelDisplayEx(pDesc->pSchema, trsupport->localBuffer->data, trsupport->localBuffer->numOfElems,
trsupport->localBuffer->numOfElems, colInfo); trsupport->localBuffer->numOfElems, colInfo);
#endif #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, // each result for a vnode is ordered as an independant list,
// then used as an input of loser tree for disk-based merge routine // then used as an input of loser tree for disk-based merge routine
......
...@@ -29,10 +29,15 @@ extern int64_t tsPageSize; ...@@ -29,10 +29,15 @@ extern int64_t tsPageSize;
extern int64_t tsOpenMax; extern int64_t tsOpenMax;
extern int64_t tsStreamMax; extern int64_t tsStreamMax;
extern int32_t tsNumOfCores; extern int32_t tsNumOfCores;
extern int32_t tsTotalDiskGB; extern float tsTotalLogDirGB;
extern float tsDiskAvailGB; extern float tsTotalTmpDirGB;
extern float tsDiskUsedGB; extern float tsTotalDataDirGB;
extern float tsDiskMinimalGB; 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 tsTotalMemoryMB;
extern int32_t tsVersion; extern int32_t tsVersion;
......
...@@ -273,7 +273,7 @@ int monitorBuildCpuSql(char *sql) { ...@@ -273,7 +273,7 @@ int monitorBuildCpuSql(char *sql) {
// unit is GB // unit is GB
int monitorBuildDiskSql(char *sql) { int monitorBuildDiskSql(char *sql) {
return sprintf(sql, ", %f, %d", tsDiskUsedGB, tsTotalDiskGB); return sprintf(sql, ", %f, %d", (tsTotalDataDirGB - tsAvailDataDirGB), (int32_t)tsTotalDataDirGB);
} }
// unit is Kb // unit is Kb
......
...@@ -64,7 +64,7 @@ void mgmtProcessDnodeStatus(void *handle, void *tmrId) { ...@@ -64,7 +64,7 @@ void mgmtProcessDnodeStatus(void *handle, void *tmrId) {
float memoryUsedMB = 0; float memoryUsedMB = 0;
taosGetSysMemory(&memoryUsedMB); taosGetSysMemory(&memoryUsedMB);
pObj->memoryAvailable = tsTotalMemoryMB - memoryUsedMB; pObj->memoryAvailable = tsTotalMemoryMB - memoryUsedMB;
pObj->diskAvailable = tsDiskAvailGB; pObj->diskAvailable = tsAvailDataDirGB;
for (int vnode = 0; vnode < pObj->numOfVnodes; ++vnode) { for (int vnode = 0; vnode < pObj->numOfVnodes; ++vnode) {
SVnodeLoad *pVload = &(pObj->vload[vnode]); SVnodeLoad *pVload = &(pObj->vload[vnode]);
......
...@@ -2656,7 +2656,7 @@ static void vnodeOpenAllFiles(SQInfo *pQInfo, int32_t vnodeId) { ...@@ -2656,7 +2656,7 @@ static void vnodeOpenAllFiles(SQInfo *pQInfo, int32_t vnodeId) {
int32_t firstFid = pVnode->fileId - pVnode->numOfFiles + 1; int32_t firstFid = pVnode->fileId - pVnode->numOfFiles + 1;
if (fid > pVnode->fileId || fid < firstFid) { 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); firstFid, pVnode->fileId);
continue; continue;
} }
......
...@@ -471,8 +471,8 @@ int vnodeProcessShellSubmitRequest(char *pMsg, int msgLen, SShellObj *pObj) { ...@@ -471,8 +471,8 @@ int vnodeProcessShellSubmitRequest(char *pMsg, int msgLen, SShellObj *pObj) {
goto _submit_over; goto _submit_over;
} }
if (tsDiskAvailGB < tsDiskMinimalGB) { if (tsAvailDataDirGB < tsMinimalDataDirGB) {
dError("server disk space remain %.3f GB, need at least %.2f GB, stop writing", tsDiskAvailGB, tsDiskMinimalGB); dError("server disk space remain %.3f GB, need at least %.3f GB, stop writing", tsAvailDataDirGB, tsMinimalDataDirGB);
code = TSDB_CODE_SERVER_NO_SPACE; code = TSDB_CODE_SERVER_NO_SPACE;
goto _submit_over; goto _submit_over;
} }
......
...@@ -34,10 +34,15 @@ int64_t tsPageSize; ...@@ -34,10 +34,15 @@ int64_t tsPageSize;
int64_t tsOpenMax; int64_t tsOpenMax;
int64_t tsStreamMax; int64_t tsStreamMax;
int32_t tsNumOfCores = 1; int32_t tsNumOfCores = 1;
int32_t tsTotalDiskGB = 0; float tsTotalLogDirGB = 0;
float tsDiskAvailGB = 0; float tsTotalTmpDirGB = 0;
float tsDiskUsedGB = 0; float tsTotalDataDirGB = 0;
float tsDiskMinimalGB = 0.5; 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 tsTotalMemoryMB = 0;
int32_t tsVersion = 0; int32_t tsVersion = 0;
...@@ -507,6 +512,13 @@ void tsInitGlobalConfig() { ...@@ -507,6 +512,13 @@ void tsInitGlobalConfig() {
tsInitConfigOption(cfg++, "maxVnodeConnections", &tsMaxVnodeConnections, TSDB_CFG_VTYPE_INT, 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); 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 // module configs
tsInitConfigOption(cfg++, "enableHttp", &tsEnableHttpModule, TSDB_CFG_VTYPE_INT, 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); TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 0, 1, 1, TSDB_CFG_UTYPE_NONE);
......
...@@ -323,8 +323,10 @@ char *tprefix(char *prefix) { ...@@ -323,8 +323,10 @@ char *tprefix(char *prefix) {
} }
void tprintf(const char *const flags, int dflag, const char *const format, ...) { void tprintf(const char *const flags, int dflag, const char *const format, ...) {
if (tsTotalDiskGB != 0 && tsDiskAvailGB < (tsDiskMinimalGB/2)) { if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < (tsMinimalLogDirGB / 2)) {
printf("server disk space remain %.3f GB, stop write log\n", tsDiskAvailGB); printf("server disk space remain %.3f GB, stop write log\n", tsAvailLogDirGB);
fflush(stdout);
return;
} }
va_list argpointer; va_list argpointer;
...@@ -373,8 +375,9 @@ void tprintf(const char *const flags, int dflag, const char *const format, ...) ...@@ -373,8 +375,9 @@ void tprintf(const char *const flags, int dflag, const char *const format, ...)
} }
void taosDumpData(unsigned char *msg, int len) { void taosDumpData(unsigned char *msg, int len) {
if (tsTotalDiskGB != 0 && tsDiskAvailGB < (tsDiskMinimalGB/2)) { if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < (tsMinimalLogDirGB / 2)) {
printf("server disk space remain %.3f GB, stop write log\n", tsDiskAvailGB); printf("server disk space remain %.3f GB, stop write log\n", tsAvailLogDirGB);
fflush(stdout);
return; return;
} }
...@@ -401,8 +404,9 @@ void taosDumpData(unsigned char *msg, int len) { ...@@ -401,8 +404,9 @@ void taosDumpData(unsigned char *msg, int len) {
} }
void taosPrintLongString(const char *const flags, int dflag, const char *const format, ...) { void taosPrintLongString(const char *const flags, int dflag, const char *const format, ...) {
if (tsTotalDiskGB != 0 && tsDiskAvailGB < (tsDiskMinimalGB/2)) { if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < (tsMinimalLogDirGB / 2)) {
printf("server disk space remain %.3f GB, stop write log\n", tsDiskAvailGB); printf("server disk space remain %.3f GB, stop write log\n", tsAvailLogDirGB);
fflush(stdout);
return; return;
} }
......
...@@ -326,15 +326,29 @@ bool taosGetDisk() { ...@@ -326,15 +326,29 @@ bool taosGetDisk() {
struct statvfs info; struct statvfs info;
const double unit = 1024 * 1024 * 1024; const double unit = 1024 * 1024 * 1024;
if (statvfs(tsDirectory, &info)) { if (statvfs(dataDir, &info)) {
tsDiskUsedGB = 0; tsTotalDataDirGB = 0;
tsTotalDiskGB = 0; tsAvailDataDirGB = 0;
return false; 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); if (statvfs("/tmp", &info)) {
tsTotalDiskGB = (int32_t)((double)info.f_blocks * (double)info.f_frsize / unit); tsAvailTmpDirGB = 0;
tsDiskUsedGB = (float)tsTotalDiskGB - tsDiskAvailGB; 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; return true;
} }
...@@ -563,7 +577,7 @@ void tsPrintOsInfo() { ...@@ -563,7 +577,7 @@ void tsPrintOsInfo() {
pPrint(" os openMax: %ld", tsOpenMax); pPrint(" os openMax: %ld", tsOpenMax);
pPrint(" os streamMax: %ld", tsStreamMax); pPrint(" os streamMax: %ld", tsStreamMax);
pPrint(" os numOfCores: %d", tsNumOfCores); pPrint(" os numOfCores: %d", tsNumOfCores);
pPrint(" os totalDisk: %d(GB)", tsTotalDiskGB); pPrint(" os totalDisk: %f(GB)", tsTotalDataDirGB);
pPrint(" os totalMemory: %d(MB)", tsTotalMemoryMB); pPrint(" os totalMemory: %d(MB)", tsTotalMemoryMB);
struct utsname buf; struct utsname buf;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册