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

Use Hash of Serialized DAG to determine DAG is changed or not #10227

Merged
merged 2 commits into from
Aug 11, 2020

Conversation

kaxil
Copy link
Member

@kaxil kaxil commented Aug 7, 2020

closes #10116


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

@kaxil kaxil requested a review from potiuk August 7, 2020 20:30
@kaxil kaxil added this to the Airflow 1.10.12 milestone Aug 7, 2020
@kaxil
Copy link
Member Author

kaxil commented Aug 9, 2020

Ping @potiuk

@@ -65,6 +66,11 @@ class SerializedDagModel(Base):
fileloc_hash = Column(BigInteger, nullable=False)
data = Column(sqlalchemy_jsonfield.JSONField(json=json), nullable=False)
last_updated = Column(UtcDateTime, nullable=False)
# TODO: Make dag_hash not nullable in Airflow 1.10.13 or Airflow 2.0??
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make it not nullable and add default value in the migration ("Hash not calculated yet"). This way it will be refreshed with the next run automagically and we will not worry about nullability.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I was tempted to do that, the only reason I didn't do it was to avoid any impression that it is a hash but I think that might not be a problem.

airflow/models/serialized_dag.py Show resolved Hide resolved
serialized_dag_hash_from_db = session.query(
cls.dag_hash).filter(cls.dag_id == dag.dag_id).scalar()

if serialized_dag_hash_from_db and (serialized_dag_hash_from_db == new_serialized_dag.dag_hash):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If make the column nullable with default this might be just ==

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@kaxil kaxil merged commit adce6f0 into apache:master Aug 11, 2020
@kaxil kaxil deleted the dag-s10n-optimization branch August 11, 2020 21:33
@potiuk
Copy link
Member

potiuk commented Aug 12, 2020

🎉 👍

kaxil added a commit that referenced this pull request Aug 13, 2020
kaxil added a commit that referenced this pull request Aug 15, 2020
cfei18 pushed a commit to cfei18/incubator-airflow that referenced this pull request Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Hash / SHA to compare Serialized DAGs
2 participants