Skip to content

Tasks beyond max_running_tasks do not get a chance to execute #386

@yjhjstz

Description

@yjhjstz

Description:

In the following code snippet:

foreach(taskCell, taskList)
{
	CronTask *task = (CronTask *) lfirst(taskCell);
	PostgresPollingStatusType pollingStatus = task->pollingStatus;
	struct pollfd *pollFileDescriptor = &pollFDs[activeTaskCount];

	if (activeTaskCount >= max_running_tasks)
	{
		/* already polling the maximum number of tasks */
		break;
	}
}

It seems that any task beyond the max_running_tasks limit never gets a chance to execute, because the loop breaks as soon as the active task count reaches the limit. This raises the concern that tasks later in the list might be completely ignored, especially if activeTaskCount is never decremented or reset elsewhere for polling new tasks.

Could you clarify:
• Is there any logic that allows the skipped tasks to be retried in a subsequent cycle?
• If not, should the code be changed to process all tasks, even if only a limited number can be active at a time?

This might lead to starvation for tasks that are always queued behind the currently running ones.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions