wjddn279 opened a new pull request, #61077: URL: https://github.com/apache/airflow/pull/61077
closed: https://github.com/apache/airflow/issues/60868 ## Reason the Issue occurs? To summarize the issue: when dag_parsing occurs, there is no increase in the Dag version, but when the command `airflow dags reserialize` is executed, an increase in the Dag version is observed. For the following Dag, I confirmed that the hash result from parsing in the dag_processor differs from the hash result through the airflow command. Upon checking the serialized values, I found that the order of the following two fields was different: ``` // dag_processor 'task_group': { "children": { "bear": ["bear", "operator"] } } // airflow command 'task_group': { "children": { "bear": ["operator", "bear"] } } ``` I understood that sorting should be applied to the values, so I needed to investigate the cause of this discrepancy. ## Deep Dive Initially, I checked whether there were differences in the logic between the dag_processor and the airflow command parsing logic, but they were identical. Therefore, I logged and compared the serialize_dag before sorting was applied. the location of each logging is here ( [dag_data](https://github.com/apache/airflow/blob/3.1.6/airflow-core/src/airflow/models/serialized_dag.py#L342,) [data_](https://github.com/apache/airflow/blob/3.1.6/airflow-core/src/airflow/models/serialized_dag.py#L344,) [data_json](https://github.com/apache/airflow/blob/3.1.6/airflow-core/src/airflow/models/serialized_dag.py#L350)) ``` // serialized dag from airflow dags command 'children': {'bear': (<DagAttributeTypes.OP: 'operator'>, 'bear')} // state after sorting dict 'children': {'bear': (<DagAttributeTypes.OP: 'operator'>, 'bear')} // state after json.loads in here 'children': {'bear': ['operator', 'bear']} // serialized dag from dag_processor 'children': {'bear': ['operator', 'bear']} // state after sorting dict 'children': {'bear': ['bear', 'operator']} // state after json.loads in here 'children': {'bear': ['bear', 'operator']} ``` The parsing results were different from the start. In fact, the Dag parsing result should match what's generated from the airflow dags command. However, I inferred that in the dag_processor, the format was changed during the dumps process of the model for inter-subprocess communication. I confirmed that the result from the airflow dags command was also changed to match the dag_processor format after json.loads was applied (enum -> str, tuple -> list). Ironically, the dag_processor, where the format was changed, had sorting applied correctly, while the airflow dags command did not, resulting in the discrepancy between the two. ## Solution The standard solution would be to control the values that change in the dag_processor, but this appears to be impossible with the current approach. Therefore, I modified the existing task_group serialization method to align with the dag_processor's format. <!-- Thank you for contributing! Please provide above a brief description of the changes made in this pull request. Write a good git commit message following this guide: http://chris.beams.io/posts/git-commit/ Please make sure that your code changes are covered with tests. And in case of new features or big changes remember to adjust the documentation. Feel free to ping (in general) for the review if you do not see reaction for a few days (72 Hours is the minimum reaction time you can expect from volunteers) - we sometimes miss notifications. In case of an existing issue, reference it using one of the following: * closes: #ISSUE * related: #ISSUE --> --- ##### Was generative AI tooling used to co-author this PR? <!-- If generative AI tooling has been used in the process of authoring this PR, please change below checkbox to `[X]` followed by the name of the tool, uncomment the "Generated-by". --> - [ ] Yes (please specify the tool below) <!-- Generated-by: [Tool Name] following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) --> --- * Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information. Note: commit author/co-author name and email in commits become permanently public when merged. * For fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed. * When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x). * For significant user-facing changes create newsfragment: `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments). -- 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]
