提交 ce381225 编写于 作者: G Ganlin Zhao

fix negative req_insert numbers

上级 1c16959a
......@@ -243,23 +243,13 @@ SDnodeStatisInfo dnodeGetStatisInfo() {
#ifdef HTTP_EMBEDDED
info.httpReqNum = httpGetReqCount();
#endif
info.queryReqNum = atomic_load_32(&tsQueryReqNum);
info.submitReqNum = atomic_load_32(&tsSubmitReqNum);
info.queryReqNum = atomic_exchange_32(&tsQueryReqNum, 0);
info.submitReqNum = atomic_exchange_32(&tsSubmitReqNum, 0);
}
return info;
}
void dnodeClearStatisInfo() {
if (dnodeGetRunStatus() == TSDB_RUN_STATUS_RUNING) {
#ifdef HTTP_EMBEDDED
httpClearReqCount();
#endif
atomic_exchange_32(&tsQueryReqNum, 0);
atomic_exchange_32(&tsSubmitReqNum, 0);
}
}
int32_t dnodeGetHttpStatusInfo(int32_t index) {
int32_t httpStatus = 0;
#ifdef HTTP_EMBEDDED
......
......@@ -31,7 +31,6 @@ typedef struct {
} SDnodeStatisInfo;
SDnodeStatisInfo dnodeGetStatisInfo();
void dnodeClearStatisInfo();
int32_t dnodeGetHttpStatusInfo(int32_t index);
void dnodeClearHttpStatusInfo();
......
......@@ -87,7 +87,6 @@ void vnodeFreeFromWQueue(void *pVnode, SVWriteMsg *pWrite);
int32_t vnodeProcessWrite(void *pVnode, void *pHead, int32_t qtype, void *pRspRet);
SVnodeStatisInfo vnodeGetStatisInfo();
void vnodeClearStatisInfo();
// vnodeSync
void vnodeConfirmForward(void *pVnode, uint64_t version, int32_t code, bool force);
......
......@@ -149,10 +149,14 @@ typedef struct {
} SMonConn;
typedef struct {
SDnodeStatisInfo dInfo;
SVnodeStatisInfo vInfo;
float io_read;
float io_write;
float io_read_disk;
float io_write_disk;
int32_t monQueryReqCnt;
int32_t monSubmitReqCnt;
} SMonStat;
static void *monHttpStatusHashTable;
......@@ -170,7 +174,6 @@ static void monSaveSlowQueryInfo();
static void monSaveDisksInfo();
static void monSaveGrantsInfo();
static void monSaveHttpReqInfo();
static void monClearStatisInfo();
static void monGetSysStats();
static void *monThreadFunc(void *param);
static void monBuildMonitorSql(char *sql, int32_t cmd);
......@@ -503,6 +506,12 @@ static void monGetSysStats() {
if (!suc) {
monDebug("failed to get io info");
}
tsMonStat.dInfo = dnodeGetStatisInfo();
tsMonStat.vInfo = vnodeGetStatisInfo();
tsMonStat.monQueryReqCnt = monFetchQueryReqCnt();
tsMonStat.monSubmitReqCnt = monFetchSubmitReqCnt();
}
// unit is MB
......@@ -554,7 +563,7 @@ static int32_t monBuildBandSql(char *sql) {
}
static int32_t monBuildReqSql(char *sql) {
SDnodeStatisInfo info = dnodeGetStatisInfo();
SDnodeStatisInfo info = tsMonStat.dInfo;
return sprintf(sql, ", %d, %d, %d)", info.httpReqNum, info.queryReqNum, info.submitReqNum);
}
......@@ -882,23 +891,22 @@ static int32_t monBuildNetworkIOSql(char *sql) {
}
static int32_t monBuildDnodeReqSql(char *sql) {
SDnodeStatisInfo dInfo = dnodeGetStatisInfo();
SVnodeStatisInfo vInfo = vnodeGetStatisInfo();
int32_t monQueryReqCnt = monFetchQueryReqCnt();
int32_t monSubmitReqCnt = monFetchSubmitReqCnt();
int32_t queryReqNum = tsMonStat.dInfo.queryReqNum - tsMonStat.monQueryReqCnt;
int32_t submitReqNum = tsMonStat.dInfo.submitReqNum - tsMonStat.monSubmitReqCnt;
int32_t submitRowNum = tsMonStat.vInfo.submitRowNum - tsMonStat.monSubmitReqCnt;
int32_t submitReqSucNum = tsMonStat.vInfo.submitReqSucNum - tsMonStat.monSubmitReqCnt;
int32_t submitRowSucNum = tsMonStat.vInfo.submitRowSucNum - tsMonStat.monSubmitReqCnt;
float interval = (float)(tsMonitorInterval * 1.0);
float httpReqRate = dInfo.httpReqNum / interval;
float queryReqRate = (dInfo.queryReqNum - monQueryReqCnt)/ interval;
float submitReqRate = (dInfo.submitReqNum - monSubmitReqCnt) / interval;
float submitRowRate = (vInfo.submitRowNum - monSubmitReqCnt) / interval;
monClearStatisInfo();
return sprintf(sql, ", %d, %f, %d, %f, %d, %d, %f, %d, %d, %f", dInfo.httpReqNum, httpReqRate,
dInfo.queryReqNum - monQueryReqCnt, queryReqRate,
vInfo.submitRowNum - monSubmitReqCnt, vInfo.submitRowSucNum - monSubmitReqCnt, submitRowRate,
dInfo.submitReqNum - monSubmitReqCnt, vInfo.submitReqSucNum - monSubmitReqCnt, submitReqRate);
float httpReqRate = tsMonStat.dInfo.httpReqNum / interval;
float queryReqRate = queryReqNum / interval;
float submitReqRate = submitReqNum / interval;
float submitRowRate = submitRowNum / interval;
return sprintf(sql, ", %d, %f, %d, %f, %d, %d, %f, %d, %d, %f", tsMonStat.dInfo.httpReqNum, httpReqRate,
queryReqNum, queryReqRate,
submitRowNum, submitRowSucNum, submitRowRate,
submitReqNum, submitReqSucNum, submitReqRate);
}
static int32_t monBuildDnodeErrorsSql(char *sql) {
......@@ -1316,11 +1324,6 @@ static void monSaveHttpReqInfo() {
}
}
static void monClearStatisInfo() {
dnodeClearStatisInfo();
vnodeClearStatisInfo();
}
static void monExecSqlCb(void *param, TAOS_RES *result, int32_t code) {
int32_t c = taos_errno(result);
if (c != TSDB_CODE_SUCCESS) {
......
......@@ -441,15 +441,9 @@ void vnodeWaitWriteCompleted(SVnodeObj *pVnode) {
SVnodeStatisInfo vnodeGetStatisInfo() {
SVnodeStatisInfo info = {0};
info.submitReqSucNum = atomic_load_32(&tsSubmitReqSucNum);
info.submitRowNum = atomic_load_32(&tsSubmitRowNum);
info.submitRowSucNum = atomic_load_32(&tsSubmitRowSucNum);
info.submitReqSucNum = atomic_exchange_32(&tsSubmitReqSucNum, 0);
info.submitRowNum = atomic_exchange_32(&tsSubmitRowNum, 0);
info.submitRowSucNum = atomic_exchange_32(&tsSubmitRowSucNum, 0);
return info;
}
void vnodeClearStatisInfo() {
atomic_exchange_32(&tsSubmitReqSucNum, 0);
atomic_exchange_32(&tsSubmitRowNum, 0);
atomic_exchange_32(&tsSubmitRowSucNum, 0);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册