Repository navigation
Commit 240027d
committed
fixup! Run loop gates and advance iterations atomically
A gate decision that the pinned loop would reject (continue at the iteration limit, or a stop before the limit of a fixed-count loop) was accepted by set_xcom and only rewritten into a failure when the state update arrived. By then the task runner had already run the success callbacks, so a failed or retried gate never saw its failure or retry callbacks (T7.15). The three decision checks now live in validate_loop_decision, shared by complete_loop_gate and set_xcom, so the write is refused with a 400 inside execute() and goes through normal retry and failure handling; the state-update rewrite stays as a backstop and its tests now seed the invalid decision directly.
Reading one slot of a mapped loop terminal went through resolve_current_producers, which hydrated every live producer row of the pass just to detect two producers at one index (T7.18). The candidate query is now built once and select_current_producer_ids fetches only id and region_index, sharing the ambiguity check with the full-row path. The resolver also passes the producer request fields to both functions explicitly instead of through attrs.asdict, so mypy checks them and a one-sided rename cannot slip through (T7.19).
The first region of a loop was inserted with a plain add and flush, so two verify_integrity calls racing on the same run could fail on the unique slot key before the later task instance race handling applied; it now uses DynamicRegion.get_or_create, which reuses the winner's region (T7.21).
count_loaded_task_instances registered list.append as a mapper load listener, which receives (target, context) and raised TypeError on the first loaded row, so its callers only passed while nothing loaded; it now filters in a real listener and has a positive-path test (T7.13). The retry test for the gate now asserts the DeleteXCom for the decision key so skipping the delete is caught (T7.22), and the unsuccessful gate test matches LoopMaxIterationsExceeded instead of a bare Exception (T7.17).
The lock-order test for the loop decision write and gate completion paused the writer only after its first dag_run lock and seeded the same continue the writer wrote, so a set_xcom that locked in the reverse order, or a completion that consumed a stale decision, would still have passed (T7.14). The writer now pauses after its first locking statement of any table, observed at the engine so session.scalar locks are seen too, and sleeps briefly once completion has issued its first lock, so a reversed order deadlocks; the seeded decision is stop, which a fixed-count loop rejects if completion consumes it before the writer replaces it. The test is still timing-based by necessity: the short sleep stands in for observing the lock wait directly.
When a Dag change gives a loop a different gate task id on a run that already has regions, verify_integrity raised from _create_initial_tasks and failed the whole run's integrity check even though only that loop was affected (T7.16). It now logs a warning and skips that loop so the run's other tasks and loops are still created; the loop keeps no gate and cannot advance, which the warning names.
The loop_decision flag on SetXCom and the set_xcom route carried nothing the reserved decision key did not already carry, because the route required key == LOOP_DECISION_KEY inside the flagged branch and rejected every other reserved key outside it (T7.20). The route now takes the gate branch when the key is the decision key, the field is gone from SetXCom, the client, the request handler, the Cadwyn entry and the regenerated Task SDK, Go and TypeScript supervisor schemas. The loop result read test that asserted the pass's producers were loaded now asserts no producer row is loaded, which is what the earlier id-only selection guarantees.1 parent 20a0322 commit 240027d
23 files changed
Lines changed: 328 additions & 155 deletions
File tree
- airflow-core
- src/airflow
- api_fastapi/execution_api/routes
- models
- tests/unit
- api_fastapi/execution_api/versions/head
- models
- devel-common/src/tests_common/test_utils
- go-sdk
- pkg/execution/genmodels
- schema
- task-sdk
- src/airflow/sdk
- api
- execution_time
- schema
- versions
- tests/task_sdk/execution_time
- schema
- ts-sdk
- schema
- src/generated
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
582 | 582 | | |
583 | 583 | | |
584 | 584 | | |
585 | | - | |
586 | 585 | | |
587 | 586 | | |
588 | 587 | | |
| |||
594 | 593 | | |
595 | 594 | | |
596 | 595 | | |
597 | | - | |
| 596 | + | |
598 | 597 | | |
599 | 598 | | |
600 | | - | |
601 | | - | |
| 599 | + | |
602 | 600 | | |
603 | 601 | | |
604 | 602 | | |
| |||
624 | 622 | | |
625 | 623 | | |
626 | 624 | | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
627 | 629 | | |
628 | 630 | | |
629 | 631 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
154 | 165 | | |
155 | 166 | | |
156 | 167 | | |
| |||
2246 | 2257 | | |
2247 | 2258 | | |
2248 | 2259 | | |
2249 | | - | |
2250 | | - | |
2251 | | - | |
2252 | | - | |
2253 | | - | |
2254 | | - | |
2255 | | - | |
| 2260 | + | |
2256 | 2261 | | |
2257 | 2262 | | |
2258 | 2263 | | |
| |||
2315 | 2320 | | |
2316 | 2321 | | |
2317 | 2322 | | |
2318 | | - | |
2319 | | - | |
2320 | | - | |
2321 | | - | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
2322 | 2333 | | |
2323 | 2334 | | |
2324 | 2335 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | | - | |
| 534 | + | |
| 535 | + | |
535 | 536 | | |
536 | 537 | | |
537 | 538 | | |
538 | 539 | | |
539 | 540 | | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
544 | 545 | | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
| 546 | + | |
| 547 | + | |
550 | 548 | | |
551 | 549 | | |
552 | 550 | | |
| |||
560 | 558 | | |
561 | 559 | | |
562 | 560 | | |
563 | | - | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
564 | 575 | | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | 576 | | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
584 | 584 | | |
585 | 585 | | |
586 | 586 | | |
587 | | - | |
588 | | - | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
589 | 629 | | |
590 | 630 | | |
591 | 631 | | |
| |||
632 | 672 | | |
633 | 673 | | |
634 | 674 | | |
635 | | - | |
| 675 | + | |
| 676 | + | |
636 | 677 | | |
637 | 678 | | |
638 | 679 | | |
639 | 680 | | |
640 | 681 | | |
641 | 682 | | |
| 683 | + | |
| 684 | + | |
642 | 685 | | |
643 | 686 | | |
644 | | - | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
645 | 698 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
598 | 598 | | |
599 | 599 | | |
600 | 600 | | |
601 | | - | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
602 | 612 | | |
603 | 613 | | |
604 | 614 | | |
| |||
681 | 691 | | |
682 | 692 | | |
683 | 693 | | |
684 | | - | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
0 commit comments