fix ref issue

This commit is contained in:
dapan1121 2022-04-29 11:43:14 +08:00
parent a4d4cd2a84
commit 529dc19a55
2 changed files with 8 additions and 1 deletions

View File

@ -86,6 +86,7 @@ typedef struct SSchedulerMgmt {
uint64_t sId; // schedulerId
SSchedulerCfg cfg;
SRWLatch lock;
bool exit;
int32_t jobRef;
int32_t jobNum;
SSchedulerStat stat;

View File

@ -2249,6 +2249,10 @@ int32_t schCancelJob(SSchJob *pJob) {
}
void schCloseJobRef(void) {
if (!atomic_load_8((int8_t*)&schMgmt.exit)) {
return;
}
SCH_LOCK(SCH_WRITE, &schMgmt.lock);
if (atomic_load_32(&schMgmt.jobNum) <= 0 && schMgmt.jobRef >= 0) {
taosCloseRef(schMgmt.jobRef);
@ -2390,7 +2394,7 @@ _return:
}
int32_t schedulerInit(SSchedulerCfg *cfg) {
if (schMgmt.jobRef) {
if (schMgmt.jobRef >= 0) {
qError("scheduler already initialized");
return TSDB_CODE_QRY_INVALID_INPUT;
}
@ -2754,6 +2758,8 @@ void schedulerFreeTaskList(SArray *taskList) {
}
void schedulerDestroy(void) {
atomic_store_8((int8_t*)&schMgmt.exit, 1);
if (schMgmt.jobRef >= 0) {
SSchJob *pJob = taosIterateRef(schMgmt.jobRef, 0);
int64_t refId = 0;