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

fix the issue #404

上级 20c9577e
......@@ -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
......
......@@ -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;
......
......@@ -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
......
......@@ -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]);
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册