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

Change to flask sqlalchemy db session close #309

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

bdc34
Copy link
Contributor

@bdc34 bdc34 commented Aug 26, 2024

Removes unnecessary rollback on error. The existing call to Session.remove() would already do this if there was an open transaction.

This call was the source of some errors in arxiv-browse. Errors during the .remove() call will could still happen but this change will avoid rollbacks when there are no changes and in READ_UNCOMMITTED. arxiv-browse runs in READ_UNCOMMITTED and makes no INSERT or UPDATEs.

The Sqlalchemy docs say (sqlalchemy.scoping.scoped_session.close())

"This expunges all ORM objects associated with this _orm.Session, ends any transaction in progress and
releases any _engine.Connection objects which this _orm.Session itself has checked out from associated _engine.Engine objects. The operation then leaves the _orm.Session in a state which it may be used again."

See: https://github.com/sqlalchemy/sqlalchemy/blob/5b117f3d4b38d12d61a39fc60582d4348232334f/lib/sqlalchemy/orm/scoping.py#L483

arxivce-1639

Removes unnecessary rollback on error. The existing call to Session.remove()
would already do this if there was an open transaction.

The Sqlalchemy docs say (sqlalchemy.scoping.scoped_session.close())

"This expunges all ORM objects associated with this
 :class:`_orm.Session`, ends any transaction in progress and
 :term:`releases` any :class:`_engine.Connection` objects which this
 :class:`_orm.Session` itself has checked out from associated
 :class:`_engine.Engine` objects. The operation then leaves the
 :class:`_orm.Session` in a state which it may be used again."
@bdc34 bdc34 requested a review from a team August 26, 2024 18:07
@bdc34 bdc34 merged commit ca21eaa into develop Aug 26, 2024
1 check passed
@bdc34 bdc34 deleted the bdc34/arxivce-1639-browse-errors-db-rollback branch August 26, 2024 18:32
bdc34 added a commit to arXiv/arxiv-browse that referenced this pull request Aug 26, 2024
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