ashb commented on a change in pull request #22260: URL: https://github.com/apache/airflow/pull/22260#discussion_r826385370
########## File path: airflow/migrations/versions/0105_48925b2719cb_add_map_index_to_taskfail.py ########## @@ -0,0 +1,76 @@ +# +# 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. + +"""Add map_index to TaskFail + +Drop index idx_task_fail_dag_task_date +Add FK `task_fail_ti_fkey`: TF -> TI ([dag_id, task_id, run_id, map_index]) + + + +Revision ID: 48925b2719cb +Revises: 4eaab2fe6582 +Create Date: 2022-03-14 10:31:11.220720 + +""" + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = '48925b2719cb' +down_revision = '4eaab2fe6582' +branch_labels = None +depends_on = None +airflow_version = '2.3.0' + + +def upgrade(): + """Apply Add map_index to TaskFail""" + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('task_fail', schema=None) as batch_op: + batch_op.add_column(sa.Column('run_id', sa.String(length=250), nullable=False)) + batch_op.add_column(sa.Column('map_index', sa.Integer(), server_default='-1', nullable=False)) + batch_op.drop_index('idx_task_fail_dag_task_date') + batch_op.create_index('idx_task_fail_dag_task_date', ['dag_id', 'task_id', 'run_id'], unique=False) + batch_op.create_foreign_key( + 'sla_miss_ti_fkey', Review comment: Wrong table name here :) ########## File path: airflow/models/taskinstance.py ########## @@ -1800,7 +1800,15 @@ def handle_failure( # Log failure duration dag_run = self.get_dagrun(session=session) # self.dag_run not populated by refresh_from_db - session.add(TaskFail(task, dag_run.execution_date, self.start_date, self.end_date)) + session.add( + TaskFail( + task=task, + run_id=dag_run.run_id, Review comment: ```suggestion run_id=self.run_id, ``` -- 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]
