vatsrahul1001 opened a new pull request, #74861:
URL: https://github.com/apache/airflow/pull/74861

   DynamicRegion.get_or_create_many() uses a SAVEPOINT (session.begin_nested()) 
to safely insert dynamic-mapping regions. Releasing that SAVEPOINT dispatches 
the same before_commit event as a real commit, and the scheduler's 
CommitProhibitorGuard rejected it unconditionally, raising "UNEXPECTED COMMIT - 
THIS WILL BREAK HA LOCKS!" before the Dag run's task instances could be created.
   
   This only happened for a Dag run the scheduler created from its own 
schedule: the API server's Dag run creation runs outside the scheduler's 
guarded session, so the identical SAVEPOINT release there was harmless. A 
dynamically mapped task on a real (non-manually-triggered) schedule could 
therefore never run, with the same scheduling error repeating every loop.
   
   Releasing a savepoint ends neither the outer transaction nor its row locks, 
so it cannot break the HA locks this guard protects — only the outer commit 
can, and that remains guarded.
   
   Tested against a minimal repro Dag (scheduled `.expand()` task) that 
reproduced the failure before this change and runs clean after it. Also added a 
unit test covering the guard directly: a savepoint release inside 
`prohibit_commit` no longer raises, while a real commit still does.
   
   closes: #74860
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 5)
   
   Generated-by: Claude Code (Opus 5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to