Skip to content

Task SDK: send error response on IPC decode failure - #76555

Open
meel-ayush wants to merge 1 commit into
apache:mainfrom
meel-ayush:fix-task-sdk-supervisor-ipc-deadlock
Open

meel-ayush wants to merge 1 commit into
apache:mainfrom
meel-ayush:fix-task-sdk-supervisor-ipc-deadlock

Conversation

@meel-ayush

Copy link
Copy Markdown

Description

When handle_requests() fails to deserialize or validate an incoming request frame — due to a missing discriminator, schema mismatch, or malformed payload — it was logging the exception and issuing continue. No response frame was sent back.

The task runner's CommsDecoder.send() blocks on socket.recv(4) waiting for the 4-byte length header of the reply. With nothing coming, the child process deadlocks permanently. The supervisor's heartbeat loop keeps running normally, so the scheduler's zombie detector never fires. The task stays stuck in RUNNING and holds worker capacity until manually killed.

The fix catches the exception as e and replies with ErrorResponse(error=ErrorType.GENERIC_ERROR) before continue, matching the existing pattern used for ServerResponseError and unhandled exceptions later in the same method. The send is wrapped in suppress(Exception) so a secondary socket error during the reply cannot crash the generator loop itself.

closes: #76550

Tests

  • Added test_handle_requests_decoding_error_sends_error_response in task-sdk/tests/task_sdk/execution_time/test_supervisor.py, parametrized over an unknown message type and a message missing required fields. Each case asserts the response frame carries a GENERIC_ERROR, the task runner side raises AirflowRuntimeError, and the generator loop stays alive for the next request.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

When handle_requests() fails to deserialize or validate an incoming request frame, it logged the exception and issued continue. The task runner's recv(4) call was left blocking with nothing ever coming back, deadlocking the child process indefinitely. Meanwhile the supervisor kept heartbeating the API server, so the scheduler's zombie detector never fired — the task would stay stuck in RUNNING until someone killed it manually. Catching the exception and replying with ErrorResponse(GENERIC_ERROR) before continue lets the task runner raise AirflowRuntimeError and exit cleanly.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task SDK: Supervisor IPC deadlocks child task runner on unvalidated request frames

1 participant