forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix retries causing constraint violation on MySQL with DAG Serializat…
…ion (apache#9336) The issue was caused because the `rendered_task_instance_fields` table did not have precision and hence causing `_mysql_exceptions.IntegrityError`. closes apache#9148 (cherry picked from commit 9e6b5ab)
- Loading branch information
Showing
2 changed files
with
118 additions
and
49 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
airflow/migrations/versions/a66efa278eea_add_precision_to_execution_date_in_mysql.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,61 @@ | ||
# | ||
# 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 Precision to execution_date in RenderedTaskInstanceFields table | ||
Revision ID: a66efa278eea | ||
Revises: 8f966b9c467a | ||
Create Date: 2020-06-16 21:44:02.883132 | ||
""" | ||
|
||
from alembic import op | ||
from sqlalchemy.dialects import mysql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'a66efa278eea' | ||
down_revision = '8f966b9c467a' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
TABLE_NAME = 'rendered_task_instance_fields' | ||
COLUMN_NAME = 'execution_date' | ||
|
||
|
||
def upgrade(): | ||
"""Add Precision to execution_date in RenderedTaskInstanceFields table for MySQL""" | ||
conn = op.get_bind() | ||
if conn.dialect.name == "mysql": | ||
op.alter_column( | ||
table_name=TABLE_NAME, | ||
column_name=COLUMN_NAME, | ||
type_=mysql.TIMESTAMP(fsp=6), | ||
nullable=False | ||
) | ||
|
||
|
||
def downgrade(): | ||
"""Unapply Add Precision to execution_date in RenderedTaskInstanceFields table""" | ||
conn = op.get_bind() | ||
if conn.dialect.name == "mysql": | ||
op.alter_column( | ||
table_name=TABLE_NAME, | ||
column_name=COLUMN_NAME, | ||
type_=mysql.TIMESTAMP(), | ||
nullable=False | ||
) |
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