Merge pull request #26453 from taosdata/fix/TD-30915
fix:[TD-30915]tmq exit elegantly
This commit is contained in:
commit
0d784d94d6
|
@ -455,6 +455,8 @@ enum {
|
||||||
|
|
||||||
void sqlReqLog(int64_t rid, bool killed, int32_t code, int8_t type);
|
void sqlReqLog(int64_t rid, bool killed, int32_t code, int8_t type);
|
||||||
|
|
||||||
|
void tmqMgmtClose(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,8 +57,6 @@ void taos_cleanup(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
monitorClose();
|
monitorClose();
|
||||||
taosHashCleanup(appInfo.pInstMap);
|
|
||||||
taosHashCleanup(appInfo.pInstMapByClusterId);
|
|
||||||
tscStopCrashReport();
|
tscStopCrashReport();
|
||||||
|
|
||||||
hbMgrCleanUp();
|
hbMgrCleanUp();
|
||||||
|
@ -85,6 +83,8 @@ void taos_cleanup(void) {
|
||||||
|
|
||||||
taosConvDestroy();
|
taosConvDestroy();
|
||||||
|
|
||||||
|
tmqMgmtClose();
|
||||||
|
|
||||||
tscInfo("all local resources released");
|
tscInfo("all local resources released");
|
||||||
taosCleanupCfg();
|
taosCleanupCfg();
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
|
|
|
@ -682,7 +682,7 @@ static void* monitorThreadFunc(void *param){
|
||||||
tscDebug("monitorThreadFunc start");
|
tscDebug("monitorThreadFunc start");
|
||||||
int64_t quitTime = 0;
|
int64_t quitTime = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (slowLogFlag > 0) {
|
if (atomic_load_32(&slowLogFlag) > 0 > 0) {
|
||||||
if(quitCnt == 0){
|
if(quitCnt == 0){
|
||||||
monitorSendAllSlowLogAtQuit();
|
monitorSendAllSlowLogAtQuit();
|
||||||
if(quitCnt == 0){
|
if(quitCnt == 0){
|
||||||
|
@ -727,10 +727,7 @@ static void* monitorThreadFunc(void *param){
|
||||||
}
|
}
|
||||||
tsem2_timewait(&monitorSem, 100);
|
tsem2_timewait(&monitorSem, 100);
|
||||||
}
|
}
|
||||||
|
atomic_store_32(&slowLogFlag, -2);
|
||||||
taosCloseQueue(monitorQueue);
|
|
||||||
tsem2_destroy(&monitorSem);
|
|
||||||
slowLogFlag = -2;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -826,10 +823,16 @@ void monitorClose() {
|
||||||
taosHashCleanup(monitorCounterHash);
|
taosHashCleanup(monitorCounterHash);
|
||||||
taosHashCleanup(monitorSlowLogHash);
|
taosHashCleanup(monitorSlowLogHash);
|
||||||
taosTmrCleanUp(monitorTimer);
|
taosTmrCleanUp(monitorTimer);
|
||||||
|
taosCloseQueue(monitorQueue);
|
||||||
|
tsem2_destroy(&monitorSem);
|
||||||
taosWUnLockLatch(&monitorLock);
|
taosWUnLockLatch(&monitorLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t monitorPutData2MonitorQueue(MonitorSlowLogData data){
|
int32_t monitorPutData2MonitorQueue(MonitorSlowLogData data){
|
||||||
|
if (atomic_load_32(&slowLogFlag) == -2) {
|
||||||
|
tscError("[monitor] slow log thread is exiting");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
MonitorSlowLogData* slowLogData = taosAllocateQitem(sizeof(MonitorSlowLogData), DEF_QITEM, 0);
|
MonitorSlowLogData* slowLogData = taosAllocateQitem(sizeof(MonitorSlowLogData), DEF_QITEM, 0);
|
||||||
if (slowLogData == NULL) {
|
if (slowLogData == NULL) {
|
||||||
tscError("[monitor] failed to allocate slow log data");
|
tscError("[monitor] failed to allocate slow log data");
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#define DEFAULT_ASKEP_INTERVAL 1000
|
#define DEFAULT_ASKEP_INTERVAL 1000
|
||||||
|
|
||||||
struct SMqMgmt {
|
struct SMqMgmt {
|
||||||
int8_t inited;
|
|
||||||
tmr_h timer;
|
tmr_h timer;
|
||||||
int32_t rsetId;
|
int32_t rsetId;
|
||||||
};
|
};
|
||||||
|
@ -1057,6 +1056,16 @@ void tmqFreeImpl(void* handle) {
|
||||||
|
|
||||||
taosArrayDestroyEx(tmq->clientTopics, freeClientVgImpl);
|
taosArrayDestroyEx(tmq->clientTopics, freeClientVgImpl);
|
||||||
taos_close_internal(tmq->pTscObj);
|
taos_close_internal(tmq->pTscObj);
|
||||||
|
|
||||||
|
if(tmq->commitTimer) {
|
||||||
|
taosTmrStopA(&tmq->commitTimer);
|
||||||
|
}
|
||||||
|
if(tmq->epTimer) {
|
||||||
|
taosTmrStopA(&tmq->epTimer);
|
||||||
|
}
|
||||||
|
if(tmq->hbLiveTimer) {
|
||||||
|
taosTmrStopA(&tmq->hbLiveTimer);
|
||||||
|
}
|
||||||
taosMemoryFree(tmq);
|
taosMemoryFree(tmq);
|
||||||
|
|
||||||
tscDebug("consumer:0x%" PRIx64 " closed", id);
|
tscDebug("consumer:0x%" PRIx64 " closed", id);
|
||||||
|
@ -1076,6 +1085,18 @@ static void tmqMgmtInit(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tmqMgmtClose(void) {
|
||||||
|
if (tmqMgmt.timer) {
|
||||||
|
taosTmrCleanUp(tmqMgmt.timer);
|
||||||
|
tmqMgmt.timer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tmqMgmt.rsetId >= 0) {
|
||||||
|
taosCloseRef(tmqMgmt.rsetId);
|
||||||
|
tmqMgmt.rsetId = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define SET_ERROR_MSG_TMQ(MSG) \
|
#define SET_ERROR_MSG_TMQ(MSG) \
|
||||||
if (errstr != NULL) snprintf(errstr, errstrLen, MSG);
|
if (errstr != NULL) snprintf(errstr, errstrLen, MSG);
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,7 @@ void schedulerDestroy(void) {
|
||||||
}
|
}
|
||||||
SCH_UNLOCK(SCH_WRITE, &schMgmt.hbLock);
|
SCH_UNLOCK(SCH_WRITE, &schMgmt.hbLock);
|
||||||
|
|
||||||
|
taosTmrCleanUp(schMgmt.timer);
|
||||||
qWorkerDestroy(&schMgmt.queryMgmt);
|
qWorkerDestroy(&schMgmt.queryMgmt);
|
||||||
schMgmt.queryMgmt = NULL;
|
schMgmt.queryMgmt = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue