Created
August 9, 2022 17:32
-
-
Save pingzh/8395e3f76e759ad5903a818f7b4c2ed3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
commit 8d545982a8483aec18134c198c5adf874e5e8f4a | |
Date: Mon Jul 18 15:37:32 2022 -0700 | |
Error: Specified key was too long; max key length is 767 bytes for mysql | |
5.7 | |
see: https://dev.mysql.com/doc/refman/5.7/en/innodb-limits.html | |
mysql 5.7 uses utf8mb3 charset (which is utf8), thus the max length for | |
index key should be 251 | |
diff --git a/airflow/migrations/versions/b25a55525161_increase_length_of_pool_name.py b/airflow/migrations/versions/b25a55525161_increase_length_of_pool_name.py | |
index 1989af7c2d..965a4773c0 100644 | |
--- a/airflow/migrations/versions/b25a55525161_increase_length_of_pool_name.py | |
+++ b/airflow/migrations/versions/b25a55525161_increase_length_of_pool_name.py | |
@@ -40,7 +40,8 @@ def upgrade(): | |
"""Increase column length of pool name from 50 to 256 characters""" | |
# use batch_alter_table to support SQLite workaround | |
with op.batch_alter_table('slot_pool', table_args=sa.UniqueConstraint('pool')) as batch_op: | |
- batch_op.alter_column('pool', type_=sa.String(256, **COLLATION_ARGS)) | |
+ batch_op.alter_column('pool', type_=sa.String(250, **COLLATION_ARGS)) | |
def downgrade(): | |
diff --git a/airflow/migrations/versions/e3a246e0dc1_current_schema.py b/airflow/migrations/versions/e3a246e0dc1_current_schema.py | |
index 9760232910..6c405f9c6b 100644 | |
--- a/airflow/migrations/versions/e3a246e0dc1_current_schema.py | |
+++ b/airflow/migrations/versions/e3a246e0dc1_current_schema.py | |
@@ -211,7 +211,8 @@ def upgrade(): | |
op.create_table( | |
'xcom', | |
sa.Column('id', sa.Integer(), nullable=False), | |
- sa.Column('key', sa.String(length=512, **COLLATION_ARGS), nullable=True), | |
+ sa.Column('key', sa.String(length=250, **COLLATION_ARGS), nullable=True), | |
sa.Column('value', sa.PickleType(), nullable=True), | |
sa.Column('timestamp', sa.DateTime(), default=func.now(), nullable=False), | |
sa.Column('execution_date', sa.DateTime(), nullable=False), | |
diff --git a/airflow/migrations/versions/e9304a3141f0_make_xcom_pkey_columns_non_nullable.py b/airflow/migrations/versions/e9304a3141f0_make_xcom_pkey_columns_non_nullable.py | |
index d675108993..90d3c205cd 100644 | |
--- a/airflow/migrations/versions/e9304a3141f0_make_xcom_pkey_columns_non_nullable.py | |
+++ b/airflow/migrations/versions/e9304a3141f0_make_xcom_pkey_columns_non_nullable.py | |
@@ -60,7 +60,8 @@ def upgrade(): | |
"""Apply make xcom pkey columns non-nullable""" | |
conn = op.get_bind() | |
with op.batch_alter_table('xcom') as bop: | |
- bop.alter_column("key", type_=sa.String(length=512, **COLLATION_ARGS), nullable=False) | |
+ bop.alter_column("key", type_=sa.String(length=250, **COLLATION_ARGS), nullable=False) | |
bop.alter_column("execution_date", type_=_get_timestamp(conn), nullable=False) | |
if conn.dialect.name == 'mssql': | |
bop.create_primary_key('pk_xcom', ['dag_id', 'task_id', 'key', 'execution_date']) | |
@@ -77,7 +78,8 @@ def downgrade(): | |
# columns were always non-nullable for sqlite and postgres, so leave them alone | |
if conn.dialect.name in ['mysql', 'mssql']: | |
- bop.alter_column("key", type_=sa.String(length=512, **COLLATION_ARGS), nullable=True) | |
+ bop.alter_column("key", type_=sa.String(length=250, **COLLATION_ARGS), nullable=True) | |
if conn.dialect.name == 'mssql': | |
# execution_date wasn't nullable in the other databases | |
bop.alter_column("execution_date", type_=_get_timestamp(conn), nullable=True) | |
diff --git a/airflow/models/pool.py b/airflow/models/pool.py | |
index 8ae88aabcd..53bb6a4362 100644 | |
--- a/airflow/models/pool.py | |
+++ b/airflow/models/pool.py | |
@@ -45,7 +45,8 @@ class Pool(Base): | |
__tablename__ = "slot_pool" | |
id = Column(Integer, primary_key=True) | |
- pool = Column(String(256), unique=True) | |
+ pool = Column(String(250), unique=True) | |
# -1 for infinite | |
slots = Column(Integer, default=0) | |
description = Column(Text) | |
diff --git a/airflow/models/xcom.py b/airflow/models/xcom.py | |
index 5efaa0ac54..00a3847792 100644 | |
--- a/airflow/models/xcom.py | |
+++ b/airflow/models/xcom.py | |
@@ -48,7 +48,8 @@ class BaseXCom(Base, LoggingMixin): | |
__tablename__ = "xcom" | |
- key = Column(String(512, **COLLATION_ARGS), primary_key=True) | |
+ key = Column(String(250, **COLLATION_ARGS), primary_key=True) | |
value = Column(LargeBinary) | |
timestamp = Column(UtcDateTime, default=timezone.utcnow, nullable=False) | |
execution_date = Column(UtcDateTime, primary_key=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment