yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #88765
[Bug 1962153] Re: Transition to SQLAlchemy 2.0
Reviewed: https://review.opendev.org/c/openstack/neutron-lib/+/828738
Committed: https://opendev.org/openstack/neutron-lib/commit/ef1e8abb89141db39e62eaa1cbdb73aca1ceb647
Submitter: "Zuul (22348)"
Branch: master
commit ef1e8abb89141db39e62eaa1cbdb73aca1ceb647
Author: Rodolfo Alonso Hernandez <ralonsoh@xxxxxxxxxx>
Date: Sun Feb 6 09:54:23 2022 +0000
Refactor session "is_active" handling for sqlalchemy-20
Since sqlalchemy 1.4, "session.autocommit" is False by default; in
sqlalchemy 2.0 this will be the only value accepted.
The ``_orm.Session`` is considered active when [1]:
- there is a transaction and this transaction is active
- there is no transaction [2], the class ``_orm.Session`` will
autobegin when it is first used.
The second one breaks the way Neutron considers a session is active:
only when a transaction is in place, Neutron considers a session is
active.
Depends-On: https://review.opendev.org/c/openstack/neutron/+/833247
[1]https://github.com/sqlalchemy/sqlalchemy/blob/rel_1_4/lib/sqlalchemy/orm/session.py#L3918-L3950
[2]https://github.com/sqlalchemy/sqlalchemy/blob/rel_1_4/lib/sqlalchemy/orm/session.py#L3930-L3932
Closes-Bug: #1962153
Topic: sqlalchemy-20
Change-Id: Iabaee4e556afb3dc75a82d99dc4a597fe4d7dd21
** Changed in: neutron
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1962153
Title:
Transition to SQLAlchemy 2.0
Status in neutron:
Fix Released
Bug description:
The ``Session.autocommit`` parameter is deprecated and will be removed
in SQLAlchemy version 2.0. The Session now features ``autobegin``
behavior such that the Session.begin() method may be called if a
transaction has not yet been started yet. See the section
session_explicit_begin for background.
In Neutron/neutron-lib, the property ``Session.is_active`` [1] is used
to determine if a session has an active transaction. With
"autocommit=False", the transaction is never closed once created. That
means the property will return "True" even when the transaction has
flushed all pending commands.
In order to mimic the previous behaviour, we need to find an
alternative method to decide if the session has any pending command to
be flushed.
Related topic: https://review.opendev.org/q/topic:sqlalchemy-20
[1]https://github.com/sqlalchemy/sqlalchemy/blob/878c37614efd311794aa50467dbb9e3fe972fdff/lib/sqlalchemy/orm/session.py#L3809-L3837
To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1962153/+subscriptions
References