-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
1.3.20 breaks certain Alembic patterns with ArgumentError: column object already assigned to table #5669
Comments
Hi Dmitry - first off I'm not sure if you're aware, I work on Openstack all day and this is an ironic-inspector bug, so normally what you can do here is make the launchpad bug and then find me on openstack freenode and I can help propose a new gerrit to fix. the error here is that ironic-inspector is relying upon previously undefined and quite broken behavior which is that column objects allowed themselves to be attached to multiple tables, causing them to behave incorrectly. ironic-inspector will need to modify its code to ensure that each Column object used only against a single table or operation; the alembic op.add_column() operation internally attaches the given column to a table object in order to render the appropriate SQL. so these columns can't be repurposed after the fact. |
here's a fix to the referenced code: temp_started_at = lambda: sa.Column("temp_started_at", sa.types.DateTime,
nullable=True)
temp_finished_at = lambda: sa.Column("temp_finished_at", sa.types.DateTime,
nullable=True)
uuid = sa.Column("uuid", sa.String(36), primary_key=True)
op.add_column("nodes", temp_started_at())
op.add_column("nodes", temp_finished_at())
t = sa.table('nodes', started_at, finished_at,
temp_started_at(), temp_finished_at(), uuid) |
also at best this would be an Alembic bug, where alembic could perhaps copy the column before using it for op.add_column(). |
@zzzeek I have indeed entirely forgotten that you work on openstack. Busy time.. Thank you for your explanation, I've applied it to https://review.opendev.org/759420. |
The pattern of adding a column and then reading a table with it no longer works in SQLAlchemy 1.3.20. This has been reported upstream [1] and apparently we're doing the wrong thing by reusing a column object twice. We need to disable the non-standalone job since it's really broken now, and this fix is blocking bifrost. [1] sqlalchemy/sqlalchemy#5669 Change-Id: I2fb07413e8f421f39b24acf1272771ee2097b195
* Update ironic-inspector from branch 'master' - Fix database migrations and disable the non-standalone job The pattern of adding a column and then reading a table with it no longer works in SQLAlchemy 1.3.20. This has been reported upstream [1] and apparently we're doing the wrong thing by reusing a column object twice. We need to disable the non-standalone job since it's really broken now, and this fix is blocking bifrost. [1] sqlalchemy/sqlalchemy#5669 Change-Id: I2fb07413e8f421f39b24acf1272771ee2097b195
The pattern of adding a column and then reading a table with it no longer works in SQLAlchemy 1.3.20. This has been reported upstream [1] and apparently we're doing the wrong thing by reusing a column object twice. We need to disable the non-standalone job since it's really broken now, and this fix is blocking bifrost. [1] sqlalchemy/sqlalchemy#5669 Change-Id: I2fb07413e8f421f39b24acf1272771ee2097b195 (cherry picked from commit 5678f21)
@zzzeek Hey! We're actually hitting the same error in Gnocchi, but it's kinda unclear as to what the actual cause is, because we don't seem to be reusing things as far as I can find in the code. This is the issue: And the two migrations that are throw errors are: |
so just look for combinations of table() and add_column(), for that one it's this:
use a lambda for temp_col:
right here: basically anytime you are assigning a Column to a variable:
change to a lambda:
|
Closes: gnocchixyz#1080 Related to: sqlalchemy/sqlalchemy#5669
Closes: gnocchixyz#1080 Related to: sqlalchemy/sqlalchemy#5669
Closes: #1080 Related to: sqlalchemy/sqlalchemy#5669
The pattern of adding a column and then reading a table with it no longer works in SQLAlchemy 1.3.20. This has been reported upstream [1]. [1] sqlalchemy/sqlalchemy#5669 Change-Id: I5fd1deeef9cf70794bc61c101e1d7d4379d4b96b
* Update magnum from branch 'master' - Fix database migrations The pattern of adding a column and then reading a table with it no longer works in SQLAlchemy 1.3.20. This has been reported upstream [1]. [1] sqlalchemy/sqlalchemy#5669 Change-Id: I5fd1deeef9cf70794bc61c101e1d7d4379d4b96b
we're going to fix this on the Alembic side as well as it's hitting me now too. see sqlalchemy/alembic#753 |
The pattern of adding a column and then reading a table with it no longer works in SQLAlchemy 1.3.20. This has been reported upstream [1] and apparently we're doing the wrong thing by reusing a column object twice. We need to disable the non-standalone job since it's really broken now, and this fix is blocking bifrost. [1] sqlalchemy/sqlalchemy#5669 Change-Id: I2fb07413e8f421f39b24acf1272771ee2097b195 (cherry picked from commit 5678f21)
Closes: gnocchixyz#1080 Related to: sqlalchemy/sqlalchemy#5669 (cherry picked from commit 5eeb3f0)
Closes: gnocchixyz#1080 Related to: sqlalchemy/sqlalchemy#5669 (cherry picked from commit 5eeb3f0)
Closes: #1080 Related to: sqlalchemy/sqlalchemy#5669 (cherry picked from commit 5eeb3f0)
The pattern of adding a column and then reading a table with it no longer works in SQLAlchemy 1.3.20. This has been reported upstream [1] and apparently we're doing the wrong thing by reusing a column object twice. We need to disable the non-standalone job since it's really broken now, and this fix is blocking bifrost. Also remove lower-constraints job. Plus increase memory for grenade job. And since tinyipa is not that tiny anymore, we increase the memory for the base job to 512. [1] sqlalchemy/sqlalchemy#5669 Change-Id: I2fb07413e8f421f39b24acf1272771ee2097b195 (cherry picked from commit 5678f21) (cherry picked from commit c6fdf25) (cherry picked from commit 1884ba81fd3d6166c626afd008beddaf0a33801e)
The pattern of adding a column and then reading a table with it no longer works in SQLAlchemy 1.3.20. This has been reported upstream [1]. [1] sqlalchemy/sqlalchemy#5669 Change-Id: I5fd1deeef9cf70794bc61c101e1d7d4379d4b96b (cherry picked from commit f5cf6b9)
The pattern of adding a column and then reading a table with it no longer works in SQLAlchemy 1.3.20. This has been reported upstream [1]. [1] sqlalchemy/sqlalchemy#5669 Change-Id: I5fd1deeef9cf70794bc61c101e1d7d4379d4b96b (cherry picked from commit f5cf6b9)
On mysql 8, Boolean fields create constraints which later make it impossible to alter the name of the column. See: sqlalchemy/alembic#699 Per upstream alembic recommendation, do not create constraints explicitly. sqlalchemy/alembic#699 (comment) story: 2008488 task: 41537 Signed-off-by: Spyros Trigazis <spyridon.trigazis@cern.ch> (cherry picked from commit bcf771b) Fix database migrations The pattern of adding a column and then reading a table with it no longer works in SQLAlchemy 1.3.20. This has been reported upstream [1]. [1] sqlalchemy/sqlalchemy#5669 squashed with: I5fd1deeef9cf70794bc61c101e1d7d4379d4b96b (cherry picked from commit f5cf6b9) Change-Id: I51659c6e179d7e4e2cfc5be46348fac483d76e3b
The pattern of adding a column and then reading a table with it no longer works in SQLAlchemy 1.3.20. This has been reported upstream [1]. [1] sqlalchemy/sqlalchemy#5669 Change-Id: I5fd1deeef9cf70794bc61c101e1d7d4379d4b96b (cherry picked from commit f5cf6b9)
Closes: #1080 Related to: sqlalchemy/sqlalchemy#5669 (cherry picked from commit 5eeb3f0)
Closes: #1080 Related to: sqlalchemy/sqlalchemy#5669 (cherry picked from commit 5eeb3f0)
Closes: #1080 Related to: sqlalchemy/sqlalchemy#5669 (cherry picked from commit 5eeb3f0)
On mysql 8, Boolean fields create constraints which later make it impossible to alter the name of the column. See: sqlalchemy/alembic#699 Per upstream alembic recommendation, do not create constraints explicitly. sqlalchemy/alembic#699 (comment) story: 2008488 task: 41537 Signed-off-by: Spyros Trigazis <spyridon.trigazis@cern.ch> (cherry picked from commit bcf771b) Fix database migrations The pattern of adding a column and then reading a table with it no longer works in SQLAlchemy 1.3.20. This has been reported upstream [1]. [1] sqlalchemy/sqlalchemy#5669 squashed with: I5fd1deeef9cf70794bc61c101e1d7d4379d4b96b (cherry picked from commit f5cf6b9) Change-Id: I51659c6e179d7e4e2cfc5be46348fac483d76e3b (cherry picked from commit 210984f) Conflicts: magnum/db/sqlalchemy/alembic/versions/1d045384b966_add_insecure_baymodel_attr.py Change-Id: Iba6f68822e4c7219f21ab2da252802dc7c3ca933
Abandoned Work around found, upstream bug report posted sqlalchemy/sqlalchemy#5669 but it's unclear if it's actually a bug. Patch-set: 1 Status: abandoned
Describe the bug
The ironic-inspector project is using two instances of a similar pattern in its alembic migrations: add a column, then load a table, then do some data manipulations. Here is a concise example. This has worked up to and including 1.3.19 and fails in 1.3.20 with ArgumentError.
Expected behavior
I would be happy if it continued to work. Maybe we're doing something exceptionally stupid? Then some guidance is welcome. We are working around the problem by switching to reflection for Table.
To Reproduce
You can do it using the ironic-inspector code tree:
Downgrade SQLAlchemy to see it working again:
Error
Versions.
Have a nice day!
The text was updated successfully, but these errors were encountered: