Add flush_on_subtransaction=True to engine config

By default, the new enginefacade doesn't emulate the same
autoflush behavior we had on exits of session context managers
with the old style. As of olso.db 4.18, we have an option to
get this same behavior. This patch implements it in our db.api
to help with the adoption of the new enginefacade by providing
the same flush semantics.

Related-Bug: #1664643
Partially-Implements: blueprint enginefacade-switch
Change-Id: I71e274d0f0199896f28daae6db71241d9b43a2f3
This commit is contained in:
Kevin Benton 2017-04-04 01:39:26 -07:00
parent f65ae58226
commit 72a2e9df96
2 changed files with 7 additions and 1 deletions

View File

@ -22,7 +22,7 @@ def _create_context_manager():
global _CTX_MANAGER
if _CTX_MANAGER is None:
_CTX_MANAGER = enginefacade.transaction_context()
_CTX_MANAGER.configure(sqlite_fk=True)
_CTX_MANAGER.configure(sqlite_fk=True, flush_on_subtransaction=True)
return _CTX_MANAGER

View File

@ -0,0 +1,6 @@
---
fixes:
- The oslo.db context manager returned by ``db.api.get_context_manager()``
will be configured with flush_on_subtransaction=True to more closely
match the behavior of the previous session.begin(subtransactions=True)
pattern we used everywhere before. See bug 1664643 for more details.