dstandish commented on issue #69938:
URL: https://github.com/apache/airflow/issues/69938#issuecomment-4994560379

   Opened #69977 to address this.
   
   **Fix taken:** route MySQL to a single-statement `INSERT ... ON DUPLICATE 
KEY UPDATE`
   (a no-op update on conflict), mirroring the existing PostgreSQL `ON CONFLICT 
DO NOTHING`
   bulk path. This removes the per-row `SAVEPOINT` loop (and the secondary
   `SAVEPOINT ... does not exist` error) and collapses the fan-out into one 
statement, holding
   locks far more briefly — the practical mitigation for the InnoDB deadlock.
   
   **On the deadlock-retry backstop** originally proposed here: after tracing 
the call path on
   `main`, a clean localized retry is not feasible, so it is intentionally not 
part of this fix.
   Asset-event registration runs inside the execution API TI state-update 
request
   (`_create_ti_state_update_query_and_update_state` → 
`TaskInstance.register_asset_changes_in_db`
   → `AssetManager.register_asset_change`), whose transaction owner is the 
whole FastAPI request
   (`SessionDep`); there is no request-level deadlock retry in the execution 
API. Since a deadlock
   aborts that entire transaction:
   
   - a `@retry_db_transaction` on the queueing method cannot revive the aborted 
outer transaction;
   - splitting the queueing into its own retried transaction would break the 
atomicity the design
     requires — the queue rows must commit in the same transaction as the 
`ti.state` change, or a
     task could be marked SUCCESS while its downstream queueing rolls back;
   - retrying the entire execution-API request would be a cross-cutting change 
across all
     endpoints, out of scope here.
   
   The bulk upsert is therefore the appropriate resolution, and #69977 closes 
this.
   
   ---
   Drafted-by: Claude Code (Opus 4.8) (no human review before posting)
   


-- 
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