Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing AUTOINC/SERIAL for FAB tables #26885

Merged
merged 4 commits into from Oct 7, 2022

Conversation

ashb
Copy link
Member

@ashb ashb commented Oct 5, 2022

In 1.10.13 we introduced a migration that creates the tables with the server_default but that migration only did anything if the tables didn't already exist. But the tables created by the FAB model have a default (but not a server_default).

Oh, and the final bit of the puzzle, in 2.4 we finally "took control" of the FAB security models in to airflow and those do not have the default set.

Fixes #26497

@ashb ashb requested review from kaxil and potiuk as code owners October 5, 2022 14:49
@ashb ashb added the type:bug-fix Changelog: Bug Fixes label Oct 5, 2022
@ashb ashb added this to the Airflow 2.4.2 milestone Oct 5, 2022
@uranusjr uranusjr force-pushed the fab-tables-missing-autoinc-pre-1-10-12 branch from e34f48c to 43af374 Compare October 6, 2022 03:32
@kaxil kaxil force-pushed the fab-tables-missing-autoinc-pre-1-10-12 branch from 43af374 to 748a7c9 Compare October 6, 2022 14:53
In 1.10.13 we introduced a migration that creates the tables with the
server_default but that migration only did anything if the tables didn't
already exist. But the tables created by the FAB model have a default
(but not a server_default).

Oh, and the final bit of the puzzle, in 2.4 we finally "took control" of
the FAB security models in to airflow and those do not have the default
set.
@ashb ashb force-pushed the fab-tables-missing-autoinc-pre-1-10-12 branch from 748a7c9 to 60d01a9 Compare October 7, 2022 10:04
@ashb
Copy link
Member Author

ashb commented Oct 7, 2022

The change to make alembic re-use the existing connection didn't fix the problem because we have some migrations that make use of create_session() (or worse, FAB models that have it's own session) and those open a new connection to the DB directly, meaning we have 3 or 4 connections to the DB from just the migrations, meaning mysql still hangs.

🤔

uranusjr and others added 2 commits October 7, 2022 16:46
Without this `create_session()` will open a new connection, and that causes mysql
to hang waiting to get a "metadata lock on table".

Using the "stock" pool with size=1 and max_overflow=0 doesn't work, that
instead times out if you try to get a new connection from the pool.
SingletonThreadPool instead returns the existing active connection which
is what we want.
@ashb ashb force-pushed the fab-tables-missing-autoinc-pre-1-10-12 branch from 4f21833 to 9981a9f Compare October 7, 2022 15:48
@ashb ashb merged commit 7efdeed into apache:main Oct 7, 2022
@ashb ashb deleted the fab-tables-missing-autoinc-pre-1-10-12 branch October 7, 2022 16:37
ephraimbuddy pushed a commit that referenced this pull request Oct 18, 2022
* Add missing AUTOINC/SERIAL for FAB tables

In 1.10.13 we introduced a migration that creates the tables with the
server_default but that migration only did anything if the tables didn't
already exist. But the tables created by the FAB model have a default
(but not a server_default).

Oh, and the final bit of the puzzle, in 2.4 we finally "took control" of
the FAB security models in to airflow and those do not have the default
set.

* Update airflow/migrations/versions/0118_2_4_2_add_missing_autoinc_fab.py

* Fix static checks

* Run migrations with with a pool of a connection.

Without this `create_session()` will open a new connection, and that causes mysql
to hang waiting to get a "metadata lock on table".

Using the "stock" pool with size=1 and max_overflow=0 doesn't work, that
instead times out if you try to get a new connection from the pool.
SingletonThreadPool instead returns the existing active connection which
is what we want.

Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
(cherry picked from commit 7efdeed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrading to airflow 2.4.0 from 2.3.4 causes NotNullViolation error
7 participants