forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move TaskInstance heartbeat directly on to TI row, not on Job row (ap…
…ache#43599) This is part of the work for AIP-72 epic, but is done as a separate PR for ease of review. This PR by itself doesn't remove the LocalTaskJob row (that will happen in a future PR when the execution code is moved over to live in the TaskSDK) but this paves the way for it. The reason we are making this change is: - Having a separate row for tracking TI heartbeat is not really buying us much - With the addition of TaskInstanceHistory we don't need _another_ separate record of when/where TIs were run - It simplifies things (one less join in finding zombies) - Makes zombie tracking easier -- it is now just on the TI state, not the combination of TI and Job state.
- Loading branch information
Showing
26 changed files
with
294 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
airflow/migrations/versions/0045_3_0_0_add_last_heartbeat_at_directly_to_ti.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# | ||
# 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 last_heartbeat_at directly to TI. | ||
Revision ID: d8cd3297971e | ||
Revises: 5f57a45b8433 | ||
Create Date: 2024-11-01 12:14:59.927266 | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
from airflow.migrations.db_types import TIMESTAMP | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "d8cd3297971e" | ||
down_revision = "5f57a45b8433" | ||
branch_labels = None | ||
depends_on = None | ||
airflow_version = "3.0.0" | ||
|
||
|
||
def upgrade(): | ||
with op.batch_alter_table("task_instance", schema=None) as batch_op: | ||
batch_op.add_column(sa.Column("last_heartbeat_at", TIMESTAMP(timezone=True), nullable=True)) | ||
batch_op.drop_index("ti_job_id") | ||
batch_op.create_index("ti_heartbeat", ["last_heartbeat_at"], unique=False) | ||
batch_op.drop_column("job_id") | ||
with op.batch_alter_table("task_instance_history", schema=None) as batch_op: | ||
batch_op.drop_column("job_id") | ||
|
||
|
||
def downgrade(): | ||
with op.batch_alter_table("task_instance", schema=None) as batch_op: | ||
batch_op.add_column(sa.Column("job_id", sa.INTEGER(), autoincrement=False, nullable=True)) | ||
batch_op.drop_index("ti_heartbeat") | ||
batch_op.create_index("ti_job_id", ["job_id"], unique=False) | ||
batch_op.drop_column("last_heartbeat_at") | ||
with op.batch_alter_table("task_instance_history", schema=None) as batch_op: | ||
batch_op.add_column(sa.Column("job_id", sa.INTEGER(), autoincrement=False, nullable=True)) |
Oops, something went wrong.