kaxil commented on code in PR #73005: URL: https://github.com/apache/airflow/pull/73005#discussion_r3992952575
########## airflow-core/src/airflow/migrations/versions/0134_3_4_0_fold_task_map_into_xcom_mapped_length.py: ########## @@ -0,0 +1,144 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +""" +Fold task_map into xcom.mapped_length. + +Every task_map row is written by the same execution API call that writes the +pushing task's ``return_value`` XCom row, at the same coordinates, so the length +lives on that row instead. ``task_map.keys`` is dropped rather than migrated: the Review Comment: Premise isn't right, and the PR body states it more strongly ("The `keys` column has never been written to"). `keys` was written non-NULL throughout 2.x on the normal worker path: `_execute_task` called `_record_task_map_for_downstreams`, which went through `TaskMap.from_task_instance_xcom` and sets `keys=list(value)` for a Mapping (`airflow/models/taskmap.py:109` at 2.11.0). Nothing in the 2->3 chain clears those rows, so a DB upgraded from 2.x can still have them. Dropping the column is still fine, just for the other reason in your sentence: nothing has ever read `keys` or `variant`. Co-location similarly holds at write time, but the retry purge deletes XCom rows and not task_map rows, so a TI that purges and then fails before re-pushing leaves a task_map row with no `return_value` row. That's what `test_mapped_length_dies_with_the_pushed_value` covers, so no objection, just worth not asserting they can't come apart. -- 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]
