Repository navigation
Task starts time out on PUT /rtif after the 3.3.2 to 3.4.0 upgrade #76774
Unanswered
manucorujo
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
After we upgraded from 3.3.2 to 3.4.0, most tasks failed for about 10 minutes when they started, before user code ran. We cannot reproduce it on demand, so we ask here before we open an issue.
Setup
[workers] execution_api_timeout= 5 s,execution_api_retries= 5.shared_buffers128 MB,work_mem4 MB.task_instancehas 1.18M rows (2.8 GB). One(dag_id, task_id)has 442k rows.dag_runhas 1.02M rows. We did not runairflow db clean.What happened (UTC)
ReadTimeoutafter the Task SDK retriedPUT /execution/task-instances/{id}/rtif. Per minute, 21 to 39PUT /rtifrequests took more than 5 s on the server, and the maximum was 299 s.PATCH /runtook at most 8 s. 126 task starts sent 309PUT /rtifrequests.pg_stat_activityshowed about 20 active statements fromRenderedTaskInstanceFields.delete_old_records, whichti_put_rtifcalls on every task start (viaTaskInstance.update_rtif):PUT /rtifmaximum fell from 155 s (17:02) to 24 s (17:03), then 7 s (17:05). The first autovacuum ofrtif_v2ran at 17:03:11. The first autoanalyze ran at 17:07:11. The burst of task starts after the migration also ended at about that time.[core] num_dag_runs_to_retain_rendered_fields = 0(the new pods were up at 17:07).delete_old_recordsnow returns at once. It did not end the incident, because the recovery started before it.What we think happened
The
rtif_v2DELETE in 3.4.0 (from #74222) joinstask_instance. In 3.3.2 the cleanup was a DELETE onrendered_task_instance_fieldsthat its primary key covered. Now theEXPLAINof thertif_v2DELETE is cheap: a seq scan ofrtif_v2and onetask_instance_pkeylookup per row. We did not capture the plan during the incident, so we see two possible causes:rtif_v2had no statistics after the migration, and the planner started fromtask_instancethroughti_state_lkp (dag_id, task_id, run_id, state). That reads every run of the task (up to 442k rows) with a cold cache.PUT /rtifagain while the API server still ran the first request. Requests for the same task instance then waited on the same row locks.Questions
rtif_v1cleanup still runs on every task start after the migration tortif_v2?rtif_v2,xcom_v2andlegacy_task_data_ownerand does not runANALYZEon them. Our first autoanalyze ofrtif_v2came 14 minutes after the migration. Should the migration runANALYZE, or should deployments do it after the upgrade?num_dag_runs_to_retain_rendered_fields = 0with a scheduledairflow db cleana good long-term setting? Or is there a better way to keep this cleanup out of the task start path?If this looks like a bug, we can open an issue with this data.
Drafted-by: Claude Code (Opus 5.5); reviewed by @manucorujo before posting
All reactions