wayblink opened a new pull request, #77361: URL: https://github.com/apache/airflow/pull/77361
<!-- Thank you for contributing! --> The task-attempt ownership migration (`0142`) restores archived attempts into `task_instance`. Before 3.4 every attempt of a task shared one `task_instance` row and therefore one `id`, so all of its `task_instance_history` rows carry the same `task_instance_id`. Restoring more than one of them therefore collides on the **primary key**, which the current `ON CONFLICT (task_instance_try_key)` target does not cover — on PostgreSQL the statement raises `UniqueViolation` instead of skipping, and the upgrade cannot reach the new head. That blocks every 3.4 upgrade of a database whose tasks were ever retried, which is the normal state of any real deployment. Dropping the conflict target keeps the intended semantics (insert the row unless it is already present) and covers every unique violation. The MySQL branch was already immune because it pre-filters rows that exist. The fix is verified on a 3.3.1 PostgreSQL database with retried tasks: migration completes and the resulting rows match what a retry-free database produces. Tests added cover the statement shape for PostgreSQL and the duplicate-skip behaviour against the configured backend. closes: #77360 --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — pi coding agent (DeepSeek v4.1) Generated-by: pi coding agent (DeepSeek v4.1) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) --- Drafted-by: pi coding agent (DeepSeek v4.1) (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]
