diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index 98bbbf8f73b26535030c5096f128a7f84c2b9f61..fb70a422bbc2b29b41074dde21a4b717bc1b338e 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -243,9 +243,19 @@ SStatisInfo dnodeGetStatisInfo() { #ifdef HTTP_EMBEDDED info.httpReqNum = httpGetReqCount(); #endif - info.queryReqNum = atomic_exchange_32(&tsQueryReqNum, 0); - info.submitReqNum = atomic_exchange_32(&tsSubmitReqNum, 0); + info.queryReqNum = atomic_load_32(&tsQueryReqNum); + info.submitReqNum = atomic_load_32(&tsSubmitReqNum); } 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); + } +} diff --git a/src/inc/dnode.h b/src/inc/dnode.h index 490bf0a68021c691f79a57240ea89a87302695d0..8decb0202313da399d0de9e8af145e4117461342 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -30,6 +30,7 @@ typedef struct { } SStatisInfo; SStatisInfo dnodeGetStatisInfo(); +void dnodeClearStatisInfo(); bool dnodeIsFirstDeploy(); bool dnodeIsMasterEp(char *ep); diff --git a/src/inc/http.h b/src/inc/http.h index 0d4c386cbf1e784834019c5d75847ab20b7ce8e9..4c27ceaf31b627df71ce437d97ab4d20be54cb84 100644 --- a/src/inc/http.h +++ b/src/inc/http.h @@ -23,6 +23,7 @@ extern "C" { #include int32_t httpGetReqCount(); +int32_t httpClearReqCount(); int32_t httpInitSystem(); int32_t httpStartSystem(); void httpStopSystem(); diff --git a/src/plugins/http/src/httpSystem.c b/src/plugins/http/src/httpSystem.c index 085863f4e410ec7f80e531db6045594fbed37201..435396be4a374b23d13d9c9cf8de3c8f95e9394d 100644 --- a/src/plugins/http/src/httpSystem.c +++ b/src/plugins/http/src/httpSystem.c @@ -120,4 +120,5 @@ void httpCleanUpSystem() { tsHttpServer.status = HTTP_SERVER_CLOSED; } -int32_t httpGetReqCount() { return atomic_exchange_32(&tsHttpServer.requestNum, 0); } +int32_t httpGetReqCount() { return atomic_load_32(&tsHttpServer.requestNum); } +int32_t httpClearReqCount() { return atomic_exchange_32(&tsHttpServer.requestNum, 0); } diff --git a/src/plugins/monitor/src/monMain.c b/src/plugins/monitor/src/monMain.c index 045de8e385a884da1b8d8ab7c8ff50fce7f2d9ef..7f0e656f4d623a334731302424fed05d199a87ca 100644 --- a/src/plugins/monitor/src/monMain.c +++ b/src/plugins/monitor/src/monMain.c @@ -415,8 +415,7 @@ static int32_t monBuildBandSql(char *sql) { } static int32_t monBuildReqSql(char *sql) { - //SStatisInfo info = dnodeGetStatisInfo(); - SStatisInfo info = {0}; + SStatisInfo info = dnodeGetStatisInfo(); return sprintf(sql, ", %d, %d, %d)", info.httpReqNum, info.queryReqNum, info.submitReqNum); } @@ -708,6 +707,7 @@ static int32_t monBuildDnodeReqRateSql(char *sql) { return sprintf(sql, ", %d, %f, %d, %f, %d, %f", info.httpReqNum, httpReqRate, info.queryReqNum - monFetchQueryReqCnt(), queryReqRate, info.submitReqNum - monFetchSubmitReqCnt(), submitReqRate); + dnodeClearStatisInfo(); } static int32_t monBuildDnodeErrorsSql(char *sql) {