Repository navigation
Fix scheduler crash loop from large Edge deadline callbacks - #74445
Conversation
c5d3a73 to
48a6ff8
Compare
jscheffl
left a comment
There was a problem hiding this comment.
Looks good. (Not sure about the version number though)
|
@jscheffl Can you advise on the version number? Or is there something preventing this from being merged? |
shahar1
left a comment
There was a problem hiding this comment.
The fix is the right one and the diagnosis in the description is sound (PostgreSQL rejects the oversized varchar(2048) insert, the scheduler loop rolls back and retries the same deadline forever), but one thing has changed since jscheffl approved: edge3 5.1.0 was released on 2026-10-20 with d5a2f8b41c07 as its migration head, so this migration now has to be labelled 5.2.0 everywhere it says 5.1.0 (file name, edge3_version, _REVISION_HEADS_MAP, migrations-ref.rst) before it can merge, which is the version question left open above. One smaller point inline about MySQL, where plain TEXT still caps the column at 64 KiB. CI last ran on 2026-10-14 and the merge is currently blocked, so the branch needs a rebase on main for a fresh run after the version rename anyway; the new test only fails without the fix on PostgreSQL and MySQL (SQLite does not enforce varchar lengths), which the CI matrix covers.
migrations between specific Edge3 provider versions (providers/edge3/src/airflow/providers/edge3/migrations/versions/0008_5_1_0_widen_edge_job_command.py:34)
Those migration details are mostly used here to make the users aware when and what kind of migrations will be executed during migrations between specific Edge3 provider versions. The intention here is that the "DB conscious" users might perform an analysis on the migrations and draw conclusions about the impact of the migrations on their Airflow database.
edge3_version = "5.1.0"
This answers the open version question: edge3 5.1.0 has been released since this PR was opened (Prepare providers release 2026-10-20, #75209) with d5a2f8b41c07 as its migration head, so this migration cannot be part of 5.1.0. As the branch stands, the file name, edge3_version, the migrations-ref.rst row and _REVISION_HEADS_MAP["5.1.0"] all claim it shipped in 5.1.0, and the map now points 5.1.0 at cd96a0a0e458, which airflow db-manager downgrade --to-version 5.1.0 (via _get_version_revision) would resolve to instead of the real 5.1.0 head. The next version is 5.2.0: rename the file to 0008_5_2_0_widen_edge_job_command.py, set edge3_version = "5.2.0", keep "5.1.0": "d5a2f8b41c07" in _REVISION_HEADS_MAP and add "5.2.0": "cd96a0a0e458" below it (the check-revision-heads-map prek hook regenerates the map from the migration files), and change the Edge3 Version cell of the new migrations-ref.rst row to 5.2.0.
Smaller observations
- See inline comments on
providers/edge3/src/airflow/providers/edge3/models/edge_job.py:89.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. After you've
addressed the points above and pushed an update, an Apache Airflow
maintainer — a real person — will take the next look
at the PR. The findings cite the project's review criteria;
if you think one of them is mis-applied, please reply on the
PR and a maintainer will weigh in.More on how Apache Airflow handles maintainer review:
Contributing guide.
Drafted-by: Claude Code (Fable 5.1); reviewed by shahar1 before posting
A missed deadline with a SyncCallback is queued to the EdgeExecutor as JSON in edge_job.command, which is limited to 2048 characters. The callback carries a snapshot of the Dag run (including its conf), so it can easily go over the limit; ours was about 2.3 KB. The database rejects the insert, the scheduler loop fails and rolls back, and every restart picks up the same deadline and crashes again, stopping scheduling for the whole deployment.
89746da to
c1cd1e8
Compare
|
@shahar1 thanks for the review. Both points are addressed in c1cd1e8, and the branch is rebased on
@jscheffl two of the suggestions I applied from GitHub needed correcting, since The edge3 provider tests pass locally on SQLite, Postgres and MySQL, including the new Could you take another look? Drafted-by: Claude Code (Opus 5.5); reviewed by @KidAmnesiac1 before posting |
Description
Changes the
edge_job.commandcolumn fromvarchar(2048)toText, so theEdgeExecutorcan store workloads of any size.Reason for the change
The
EdgeExecutorstores each workload as JSON inedge_job.command. ASyncCallbackdeadline workload carries a snapshot of the Dag run, including itsconf, so it can easily exceed 2048 characters. Ours was about 2.3 KB (Airflow 3.3.2, edge3 4.3.2, PostgreSQL), and the insert failed:The error escapes the scheduler loop and the transaction rolls back, so the deadline stays pending and every restarted scheduler crashes on it again. Scheduling stops for the whole deployment until the Dag run is deleted.
Fix
0008(edge3 5.2.0) changesedge_job.commandtoText(MEDIUMTEXTon MySQL). On PostgreSQL, convertingvarchartotextonly changes metadata, so the upgrade doesn't rewrite the table.EdgeJobModel.commandis nowText(MEDIUMTEXTon MySQL), and the5.2.0revision head points at the new migration.varcharlengths, so the test only catches the bug on PostgreSQL and MySQL.Related: #74446 makes the scheduler survive a callback that fails to queue for any reason. The Dag run snapshot itself comes from
get_simple_context()inDeadline.handle_miss, whoseTODOcovers fetching it at runtime instead (attempted in #66608, reverted in #68909).Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5.5) following the guidelines