Skip to content

Close connection after retrieving the current alembic version#26

Merged
martinburchell merged 3 commits intomasterfrom
alembic-metadata-lock-fix
Feb 13, 2025
Merged

Close connection after retrieving the current alembic version#26
martinburchell merged 3 commits intomasterfrom
alembic-metadata-lock-fix

Conversation

@martinburchell
Copy link
Collaborator

Since the upgrade to SQLAlchemy 2.0, CamCOPS upgrade_db was hanging when upgrading the database. This appears to be due to this open connection causing a metadata lock.

CamCOPS upgrade_db was hanging when upgrading the database due to this open connection causing a metadata lock.
@martinburchell
Copy link
Collaborator Author

@RudolfCardinal the test failures are because of this:

cardinal_pythonlib/sqlalchemy/tests/schema_tests.py:314: in <genexpr>
    col._make_proxy(t) for col in selectable.selected_columns
E   TypeError: Label._make_proxy() missing 2 required keyword-only arguments: 'primary_key' and 'foreign_keys'

since SQLAlchemy 2.0.38 i.e. unrelated to this change.

I can make the tests pass if I delete the call to _populate_separate_keys() . This line has been there from whenever that code was first written. Can you remember what this code was doing?

@RudolfCardinal
Copy link
Owner

Hmm. The use of "git blame" suggests you ;) I suspect it is a recipe from sqlalchemy/sqlalchemy#7779 . But that was a modification to something at https://github.com/sqlalchemy/sqlalchemy/wiki/Views , which itself was updated recently, for SQLAlchemy 2.0.38. So perhaps the current view recipe, which doesn't use the "internals", is the way to go?

@martinburchell
Copy link
Collaborator Author

Hmm. The use of "git blame" suggests you ;) I suspect it is a recipe from sqlalchemy/sqlalchemy#7779 . But that was a modification to something at https://github.com/sqlalchemy/sqlalchemy/wiki/Views , which itself was updated recently, for SQLAlchemy 2.0.38. So perhaps the current view recipe, which doesn't use the "internals", is the way to go?

Oh yes :) sorry! I have no memory of writing that. I am getting old. I will take a look at it.

@martinburchell martinburchell merged commit e9ad64e into master Feb 13, 2025
5 checks passed
@martinburchell martinburchell deleted the alembic-metadata-lock-fix branch February 13, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants