Lee-W commented on code in PR #59183:
URL: https://github.com/apache/airflow/pull/59183#discussion_r2605938826


##########
airflow-core/tests/unit/assets/test_manager.py:
##########
@@ -202,3 +205,88 @@ def test_create_assets_notifies_asset_listener(self, 
session):
         assert len(asset_listener.created) == 1
         assert len(asms) == 1
         assert asset_listener.created[0].uri == asset.uri == asms[0].uri
+
+    @pytest.mark.backend("mysql", "postgres")
+    @pytest.mark.usefixtures("dag_maker", "testing_dag_bundle")
+    def test_get_or_create_apdr_race_condition_non_sqlite(self, session):
+        asm = AssetModel(uri="test://asset1/", name="parition_asset", 
group="asset")
+        testing_dag = DagModel(dag_id="testing_dag", is_stale=False, 
bundle_name="testing")
+        session.add_all([asm, testing_dag])
+        session.commit()
+        session.flush()
+        assert session.query(AssetPartitionDagRun).count() == 0
+
+        assert Session
+        assert Session.session_factory
+
+        session_1 = Session.session_factory()
+        session_2 = Session.session_factory()
+        assert session_1 != session_2
+
+        session_1.begin()
+        session_2.begin()
+        apdr_1 = AssetManager._get_or_create_apdr(

Review Comment:
   I just updated the test case to make it simulate race condition better.



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