You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "kaxil (via GitHub)" <gi...@apache.org> on 2026/10/19 13:13:00 UTC

[PR] Fix `Trigger.clean_unused` rejecting a caller-provided session [airflow]

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

   #70961 removed the `session` argument from `Trigger.clean_unused()` when it moved the retry loop around a new session. A caller that runs the cleanup inside its own transaction, for example a triggerer implementation that handles events and cleans up triggers in one heartbeat transaction, now fails with `TypeError: Trigger.clean_unused() got an unexpected keyword argument 'session'`. #70961 is on `v3-4-test` (#74950), so this would ship in 3.4.0.
   
   This restores the keyword-only `session` argument and moves the retry up into `TriggerRunnerSupervisor.clean_unused()`, the one caller that owns its transaction. The model method still deletes at most one batch per call, and `Trigger.clean_unused()` without a session still runs and commits in its own transaction.
   
   **Why not keep the retry in the model and roll back the given session between attempts**, the way `retry_db_transaction` does? Because that transaction belongs to the caller. I checked this on Postgres by terminating the connection with `pg_terminate_backend` partway through the cleanup while the caller's transaction already held another write. The rollback-and-retry version reported success, the caller committed, and its earlier write was gone. Without a retry in the model, the error reaches whoever owns the transaction and nothing is lost silently. The supervisor retries on the regular scoped session, which recovers from the same dropped connection, so the `PendingRollbackError` crash from #74614 stays fixed. A Postgres-only test covers that path.
   
   One behaviour change for direct callers: `Trigger.clean_unused()` no longer retries database errors by itself. In core the supervisor was the only caller relying on that, and it now does the retry.
   
   The two caller-session tests fail on `main` with the `TypeError` above.
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix `Trigger.clean_unused` rejecting a caller-provided session [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #75096:
URL: https://github.com/apache/airflow/pull/75096#issuecomment-6271256012

   ### Backport successfully created: v3-4-test
   
   Note: As of [Merging PRs targeted for Airflow 3.X](https://github.com/apache/airflow/blob/main/dev/README_AIRFLOW3_DEV.md#merging-prs-targeted-for-airflow-3x)
   the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.
   
   In matter of doubt please ask in [#release-management](https://apache-airflow.slack.com/archives/C03G9H97MM2) Slack channel.
   
   <table>
           <tr>
           <th>Status</th>
           <th>Branch</th>
           <th>Result</th>
       </tr>
       <tr>
           <td>✅</td>
           <td>v3-4-test</td>
           <td><a href="https://github.com/apache/airflow/pull/75122"><img src="https://img.shields.io/badge/PR-75122-blue" alt="PR Link"></a></td>
       </tr>
   </table>


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix `Trigger.clean_unused` rejecting a caller-provided session [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil merged PR #75096:
URL: https://github.com/apache/airflow/pull/75096


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org