kaxil commented on PR #67902:
URL: https://github.com/apache/airflow/pull/67902#issuecomment-4607479921

   @amoghrajesh heads up, CI is red on a test this PR adds, failing on every 
backend (not flaky):
   
   
`airflow-core/tests/unit/state/test_metastore.py::TestMetastoreStoreBackendAssetScope::test_set_asset_store_upsert_updates_ti_id`
   
   ```
   sqlalchemy.exc.IntegrityError: UNIQUE constraint failed: dag_run.dag_id, 
dag_run.run_id
   ```
   
   `create_task_instance` defaults to `dag_id="dag"` with a default `run_id` 
and creates a fresh dag_run each call, so the two calls collide on the dag_run 
unique key:
   
   ```python
   ti1 = create_task_instance(task_id="task1")
   ti2 = create_task_instance(task_id="task2")
   ```
   
   Only `task_id` differs, which doesn't help since the collision is on the 
dag_run. Giving them distinct dag runs fixes it:
   
   ```python
   ti1 = create_task_instance(task_id="task1", dag_id="dag1")
   ti2 = create_task_instance(task_id="task2", dag_id="dag2")
   ```
   
   (distinct `run_id` works too). The test only needs two distinct TI ids, so 
separate dag runs satisfy the intent. The Firefox UI e2e failure looks like 
unrelated flake; the core failures are all this one test.
   


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