This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch v2-7-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 4e817c46b4c94d44b5c50665f23f19d7284b42be Author: Jarek Potiuk <[email protected]> AuthorDate: Sat Aug 5 23:15:49 2023 +0200 Fix flaky sqlite tests with `test_xcom_map_nest` hopefully (#33145) Recently sqlite started to fail randomly during teardown of `test_xcom_map_nest` or `test_xcom_map_zip_nest`. This happpened after adding `test_xcom_map_zip_nest` . It looked very strange: ``` sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread ``` By analysing possible reasons it seems that it was a side effect of the existing `test_xcom_map_nest` that allocated a new session in the run method of task instance rather than pass the sesion that is created and torrn down in the pytest fixture. The hypothesis is that the session created in the ``test_xcom_map_nest`` were being reclaimed and closed while the `test_xcom_map_zip_nest` test was already starting in a different thread started by Pytest. The fix is to pass the session object to run method of the taskinstance in the ``test_xcom_map_nest`` test. (cherry picked from commit d1d6fc994d46aaed9c801162595cae91a1ffc19c) --- tests/models/test_xcom_arg_map.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/models/test_xcom_arg_map.py b/tests/models/test_xcom_arg_map.py index e88c1a81d8..92e14da567 100644 --- a/tests/models/test_xcom_arg_map.py +++ b/tests/models/test_xcom_arg_map.py @@ -251,7 +251,7 @@ def test_xcom_map_nest(dag_maker, session): # Run "push". decision = dr.task_instance_scheduling_decisions(session=session) for ti in decision.schedulable_tis: - ti.run() + ti.run(session=session) session.flush() session.commit() @@ -262,7 +262,7 @@ def test_xcom_map_nest(dag_maker, session): # Now "pull" should apply the mapping functions in order. decision = dr.task_instance_scheduling_decisions(session=session) for ti in decision.schedulable_tis: - ti.run() + ti.run(session=session) assert results == {"aa", "bb", "cc"}
