diff --git a/src/backend/distributed/utils/background_jobs.c b/src/backend/distributed/utils/background_jobs.c index a7a124c7487..84377e2ba2a 100644 --- a/src/backend/distributed/utils/background_jobs.c +++ b/src/backend/distributed/utils/background_jobs.c @@ -706,8 +706,12 @@ TaskConcurrentCancelCheck(TaskExecutionContext *taskExecutionContext) BackgroundExecutorHashEntry *handleEntry = taskExecutionContext->handleEntry; BackgroundTask *task = GetBackgroundTaskByTaskId(handleEntry->taskid); taskExecutionContext->task = task; + if (!task) + { + ereport(ERROR, (errmsg("unexpected missing task id: %ld", handleEntry->taskid))); + } - if (!task || task->status == BACKGROUND_TASK_STATUS_CANCELLING) + if (task->status == BACKGROUND_TASK_STATUS_CANCELLING) { /* * being in that step means that a concurrent cancel or removal happened. we should