fix the issue #404
This commit is contained in:
parent
35aa9a95e4
commit
06b7af06a2
|
@ -130,6 +130,7 @@ extern "C" {
|
|||
#define TSDB_CODE_CACHE_BLOCK_TS_DISORDERED 107 // time stamp in cache block is disordered
|
||||
#define TSDB_CODE_FILE_BLOCK_TS_DISORDERED 108 // time stamp in file block is disordered
|
||||
#define TSDB_CODE_INVALID_COMMIT_LOG 109 // invalid commit log may be caused by insufficient sotrage
|
||||
#define TSDB_CODE_SERVER_NO_SPACE 110
|
||||
|
||||
// message type
|
||||
#define TSDB_MSG_TYPE_REG 1
|
||||
|
|
|
@ -30,6 +30,9 @@ 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 int32_t tsTotalMemoryMB;
|
||||
extern int32_t tsVersion;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ bool taosGetSysMemory(float *memoryUsedMB);
|
|||
|
||||
bool taosGetProcMemory(float *memoryUsedMB);
|
||||
|
||||
bool taosGetDisk(float *diskUsedGB);
|
||||
bool taosGetDisk();
|
||||
|
||||
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage);
|
||||
|
||||
|
|
|
@ -25,9 +25,10 @@
|
|||
#include "ttimer.h"
|
||||
#include "tutil.h"
|
||||
|
||||
#define SQL_LENGTH 1024
|
||||
#define LOG_LEN_STR 80
|
||||
#define IP_LEN_STR 15
|
||||
#define SQL_LENGTH 1024
|
||||
#define LOG_LEN_STR 80
|
||||
#define IP_LEN_STR 15
|
||||
#define CHECK_INTERVAL 1000
|
||||
|
||||
typedef enum {
|
||||
MONITOR_CMD_CREATE_DB,
|
||||
|
@ -53,6 +54,7 @@ typedef struct {
|
|||
int8_t state;
|
||||
char sql[SQL_LENGTH];
|
||||
void * initTimer;
|
||||
void * diskTimer;
|
||||
} MonitorConn;
|
||||
|
||||
MonitorConn *monitor = NULL;
|
||||
|
@ -69,9 +71,15 @@ void monitorSaveLog(int level, const char *const format, ...);
|
|||
void (*monitorCountReqFp)(SCountInfo *info) = NULL;
|
||||
void monitorExecuteSQL(char *sql);
|
||||
|
||||
void monitorCheckDiskUsage(void *para, void *unused) {
|
||||
taosGetDisk();
|
||||
taosTmrReset(monitorCheckDiskUsage, CHECK_INTERVAL, NULL, tscTmr, &monitor->diskTimer);
|
||||
}
|
||||
|
||||
int monitorInitSystem() {
|
||||
monitor = (MonitorConn *)malloc(sizeof(MonitorConn));
|
||||
memset(monitor, 0, sizeof(MonitorConn));
|
||||
taosTmrReset(monitorCheckDiskUsage, CHECK_INTERVAL, NULL, tscTmr, &monitor->diskTimer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -265,13 +273,7 @@ int monitorBuildCpuSql(char *sql) {
|
|||
|
||||
// unit is GB
|
||||
int monitorBuildDiskSql(char *sql) {
|
||||
float diskUsedGB = 0;
|
||||
bool suc = taosGetDisk(&diskUsedGB);
|
||||
if (!suc) {
|
||||
monitorError("monitor:%p, get disk info failed.", monitor->conn);
|
||||
}
|
||||
|
||||
return sprintf(sql, ", %f, %d", diskUsedGB, tsTotalDiskGB);
|
||||
return sprintf(sql, ", %f, %d", tsDiskUsedGB, tsTotalDiskGB);
|
||||
}
|
||||
|
||||
// unit is Kb
|
||||
|
|
|
@ -233,5 +233,6 @@ char *tsError[] = {"success",
|
|||
"invalid query message",
|
||||
"timestamp disordered in cache block",
|
||||
"timestamp disordered in file block",
|
||||
"invalid commit log"
|
||||
"invalid commit log",
|
||||
"server no disk space",
|
||||
};
|
||||
|
|
|
@ -64,10 +64,7 @@ void mgmtProcessDnodeStatus(void *handle, void *tmrId) {
|
|||
float memoryUsedMB = 0;
|
||||
taosGetSysMemory(&memoryUsedMB);
|
||||
pObj->memoryAvailable = tsTotalMemoryMB - memoryUsedMB;
|
||||
|
||||
float diskUsedGB = 0;
|
||||
taosGetDisk(&diskUsedGB);
|
||||
pObj->diskAvailable = tsTotalDiskGB - diskUsedGB;
|
||||
pObj->diskAvailable = tsDiskAvailGB;
|
||||
|
||||
for (int vnode = 0; vnode < pObj->numOfVnodes; ++vnode) {
|
||||
SVnodeLoad *pVload = &(pObj->vload[vnode]);
|
||||
|
|
|
@ -471,6 +471,12 @@ 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);
|
||||
code = TSDB_CODE_SERVER_NO_SPACE;
|
||||
goto _submit_over;
|
||||
}
|
||||
|
||||
pObj->count = pSubmit->numOfSid; // for import
|
||||
pObj->code = 0; // for import
|
||||
pObj->numOfTotalPoints = 0; // for import
|
||||
|
|
|
@ -33,9 +33,12 @@
|
|||
int64_t tsPageSize;
|
||||
int64_t tsOpenMax;
|
||||
int64_t tsStreamMax;
|
||||
int32_t tsNumOfCores;
|
||||
int32_t tsTotalDiskGB;
|
||||
int32_t tsTotalMemoryMB;
|
||||
int32_t tsNumOfCores = 1;
|
||||
int32_t tsTotalDiskGB = 0;
|
||||
float tsDiskAvailGB = 0;
|
||||
float tsDiskUsedGB = 0;
|
||||
float tsDiskMinimalGB = 0.5;
|
||||
int32_t tsTotalMemoryMB = 0;
|
||||
int32_t tsVersion = 0;
|
||||
|
||||
// global, not configurable
|
||||
|
@ -733,7 +736,7 @@ int tsCfgDynamicOptions(char *msg) {
|
|||
tsPrintGlobalConfig();
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
if (strncasecmp(option, "resetQueryCache", 15) == 0) {
|
||||
if (taosLogSqlFp) {
|
||||
pPrint("the query cache of internal client will reset");
|
||||
|
|
|
@ -323,6 +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);
|
||||
}
|
||||
|
||||
va_list argpointer;
|
||||
char buffer[MAX_LOGLINE_SIZE + 10] = {0};
|
||||
int len;
|
||||
|
@ -369,6 +373,11 @@ 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);
|
||||
return;
|
||||
}
|
||||
|
||||
char temp[256];
|
||||
int i, pos = 0, c = 0;
|
||||
|
||||
|
@ -392,6 +401,11 @@ 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);
|
||||
return;
|
||||
}
|
||||
|
||||
va_list argpointer;
|
||||
char buffer[65 * 1024 + 10];
|
||||
int len;
|
||||
|
|
|
@ -322,19 +322,19 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool taosGetDisk(float *diskUsedGB) {
|
||||
bool taosGetDisk() {
|
||||
struct statvfs info;
|
||||
const double unit = 1024 * 1024 * 1024;
|
||||
|
||||
if (statvfs(tsDirectory, &info)) {
|
||||
*diskUsedGB = 0;
|
||||
tsDiskUsedGB = 0;
|
||||
tsTotalDiskGB = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
float diskAvail = (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);
|
||||
*diskUsedGB = (float)tsTotalDiskGB - diskAvail;
|
||||
tsDiskUsedGB = (float)tsTotalDiskGB - tsDiskAvailGB;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -549,7 +549,7 @@ void taosGetSystemInfo() {
|
|||
float tmp1, tmp2;
|
||||
taosGetSysMemory(&tmp1);
|
||||
taosGetProcMemory(&tmp2);
|
||||
taosGetDisk(&tmp1);
|
||||
taosGetDisk();
|
||||
taosGetBandSpeed(&tmp1);
|
||||
taosGetCpuUsage(&tmp1, &tmp2);
|
||||
taosGetProcIO(&tmp1, &tmp2);
|
||||
|
|
Loading…
Reference in New Issue