-
Notifications
You must be signed in to change notification settings - Fork 17.4k
Fix Writing Serialized Dags to DB #9836
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,9 @@ class DagBag(BaseDagBag, LoggingMixin): | |
| with airflow or not | ||
| :type include_examples: bool | ||
| :param store_serialized_dags: Read DAGs from DB if store_serialized_dags is ``True``. | ||
| If ``False`` DAGs are read from python files. | ||
| If ``False`` DAGs are read from python files. This property is not used when | ||
| determining whether or not to write Serialized DAGs, that is done by checking | ||
| the config ``store_serialized_dags``. | ||
| :type store_serialized_dags: bool | ||
| """ | ||
|
|
||
|
|
@@ -434,6 +436,10 @@ def sync_to_db(self): | |
| # To avoid circular import - airflow.models.dagbag -> airflow.models.dag -> airflow.models.dagbag | ||
| from airflow.models.dag import DAG | ||
| from airflow.models.serialized_dag import SerializedDagModel | ||
| self.log.debug("Calling the DAG.bulk_sync_to_db method") | ||
| DAG.bulk_sync_to_db(self.dags.values()) | ||
| if self.store_serialized_dags: | ||
| # Write Serialized DAGs to DB if DAG Serialization is turned on | ||
| # Even though self.store_serialized_dags is False | ||
| if settings.STORE_SERIALIZED_DAGS: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we want to do this? If we do this then wouldn't every dagbag start writing to the DB?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is only run when dagbag.sync_to_db() is called
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And whenever
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And a note:
|
||
| self.log.debug("Calling the SerializedDagModel.bulk_sync_to_db method") | ||
| SerializedDagModel.bulk_sync_to_db(self.dags.values()) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about rename this parameter? Its name is not correct. In my opinion, it should be called "read_dags_from_db" or something similar. If it had a better name from the beginning, we could avoid the current bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have renamed it in another PR : #9838