Skip to content

Race condition - task never completes on process pool with cancellations #153

Description

@emaxx-google

I'm observing that sometimes a task submitted to a ProcessPool never completes, neither with success/failure nor with a timeout. After a lot of debugging the logs show the following sequence of events for the problematic task:

[05:57:55.093] WorkerManager.dispatch: task.id=287736
[05:57:55.100] stop_process: stopped pid=2667133
[05:57:55.138] PoolManager.process_next_message: message=Acknowledgement task.id=287736 worker_id=2667133
// here we're hung, with task id=287736 never completing;
// debug-dumping _pool_manager.task_manager.tasks shows Pebble thinks it's still running on the already-terminated worker:
{287736: Task(id=287736 worker_id=2667133)}

I believe what led to this situation is a race condition between the main process terminating the worker for some previous taskA that was cancel()ed, and the worker actually completing this taskA and moving on to acknowledging a new taskB before actually being killed - leaving the taskB in the limbo state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions