Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix write processor_subdir in serialized_dag table #35661

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions airflow/models/dagbag.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ def _sync_to_db(

log = cls.logger()

def _serialize_dag_capturing_errors(dag, session):
def _serialize_dag_capturing_errors(dag, session, processor_subdir):
"""
Try to serialize the dag to the DB, but make a note of any errors.

Expand All @@ -636,6 +636,7 @@ def _serialize_dag_capturing_errors(dag, session):
dag,
min_update_interval=settings.MIN_SERIALIZED_DAG_UPDATE_INTERVAL,
session=session,
processor_subdir=processor_subdir,
)
if dag_was_updated:
DagBag._sync_perm_for_dag(dag, session=session)
Expand Down Expand Up @@ -665,7 +666,9 @@ def _serialize_dag_capturing_errors(dag, session):
try:
# Write Serialized DAGs to DB, capturing errors
for dag in dags.values():
serialize_errors.extend(_serialize_dag_capturing_errors(dag, session))
serialize_errors.extend(
_serialize_dag_capturing_errors(dag, session, processor_subdir)
)

DAG.bulk_write_to_db(dags.values(), processor_subdir=processor_subdir, session=session)
except OperationalError:
Expand Down
4 changes: 3 additions & 1 deletion tests/models/test_dagbag.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,9 @@ def test_sync_to_db_is_retried(self, mock_bulk_write_to_db, mock_s10n_write_dag,
# and the session was roll-backed before even reaching 'SerializedDagModel.write_dag'
mock_s10n_write_dag.assert_has_calls(
[
mock.call(mock_dag, min_update_interval=mock.ANY, session=mock_session),
mock.call(
mock_dag, min_update_interval=mock.ANY, processor_subdir=None, session=mock_session
),
]
)

Expand Down