fix: scheduler timer stop issue

This commit is contained in:
dapan1121 2024-11-28 13:56:27 +08:00
parent a15120f97e
commit 90b60d9d01
6 changed files with 34 additions and 9 deletions

View File

@ -39,6 +39,8 @@ bool taosTmrStop(tmr_h tmrId);
bool taosTmrStopA(tmr_h *tmrId);
bool taosTmrIsStopped(tmr_h* timerId);
bool taosTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void *param, void *handle, tmr_h *pTmrId);
#ifdef __cplusplus

View File

@ -6115,7 +6115,7 @@ int32_t tsdbNextDataBlock2(STsdbReader* pReader, bool* hasNext) {
TSDB_CHECK_CODE(code, lino, _end);
}
goto _end;
return code;
}
}
@ -6142,7 +6142,7 @@ int32_t tsdbNextDataBlock2(STsdbReader* pReader, bool* hasNext) {
acquired = false;
TSDB_CHECK_CODE(code, lino, _end);
}
goto _end;
return code;
}
if (pReader->step == EXTERNAL_ROWS_MAIN && pReader->innerReader[1] != NULL) {
@ -6168,7 +6168,7 @@ int32_t tsdbNextDataBlock2(STsdbReader* pReader, bool* hasNext) {
TSDB_CHECK_CODE(code, lino, _end);
}
goto _end;
return code;
}
}

View File

@ -657,6 +657,7 @@ int32_t schNotifyTaskInHashList(SSchJob *pJob, SHashObj *list, ETaskNotifyType
int32_t schLaunchLevelTasks(SSchJob *pJob, SSchLevel *level);
void schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask);
int32_t schValidateSubplan(SSchJob *pJob, SSubplan* pSubplan, int32_t level, int32_t idx, int32_t taskNum);
void schStopTaskDelayTimer(SSchJob *pJob, SSchTask* pTask, bool syncOp);
int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel);
int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask);
void schDirectPostJobRes(SSchedulerReq *pReq, int32_t errCode);

View File

@ -428,9 +428,7 @@ void schResetTaskForRetry(SSchJob *pJob, SSchTask *pTask) {
schDropTaskOnExecNode(pJob, pTask);
if (pTask->delayTimer) {
if (!taosTmrStopA(&pTask->delayTimer)) {
SCH_TASK_WLOG("stop task delayTimer failed, may stopped, status:%d", pTask->status);
}
schStopTaskDelayTimer(pJob, pTask, false);
}
taosHashClear(pTask->execNodes);
(void)schRemoveTaskFromExecList(pJob, pTask); // ignore error
@ -1361,9 +1359,7 @@ void schDropTaskInHashList(SSchJob *pJob, SHashObj *list) {
SCH_LOCK_TASK(pTask);
if (pTask->delayTimer) {
if (!taosTmrStopA(&pTask->delayTimer)) {
SCH_TASK_WLOG("stop delayTimer failed, status:%d", pTask->status);
}
schStopTaskDelayTimer(pJob, pTask, true);
}
schDropTaskOnExecNode(pJob, pTask);
SCH_UNLOCK_TASK(pTask);

View File

@ -418,4 +418,16 @@ int32_t schValidateSubplan(SSchJob *pJob, SSubplan* pSubplan, int32_t level, int
return TSDB_CODE_SUCCESS;
}
void schStopTaskDelayTimer(SSchJob *pJob, SSchTask* pTask, bool syncOp) {
if (!taosTmrStopA(&pTask->delayTimer)) {
if (syncOp) {
while (!taosTmrIsStopped(&pTask->delayTimer)) {
taosMsleep(1);
}
} else {
SCH_TASK_WLOG("stop task delayTimer failed, may stopped, status:%d", pTask->status);
}
}
}

View File

@ -472,6 +472,20 @@ bool taosTmrStopA(tmr_h* timerId) {
return ret;
}
bool taosTmrIsStopped(tmr_h* timerId) {
uintptr_t id = (uintptr_t)*timerId;
tmr_obj_t* timer = findTimer(id);
if (timer == NULL) {
tmrDebug("timer[id=%" PRIuPTR "] does not exist", id);
return true;
}
uint8_t state = atomic_load_8(&timer->state);
return (state == TIMER_STATE_CANCELED) || (state == TIMER_STATE_STOPPED);
}
bool taosTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void* param, void* handle, tmr_h* pTmrId) {
tmr_ctrl_t* ctrl = (tmr_ctrl_t*)handle;
if (ctrl == NULL || ctrl->label[0] == 0) {