summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-01-29 18:25:19 -0500
committerBen Nemec <openstack@nemebean.com>2018-02-12 15:40:18 +0000
commit268edcb4e32856ce28db2bc53a9f73e79f9c2daa (patch)
tree09a55b15340a8a71f5b6bfc9a3c818bb0a8098b9
parenta1539bbc1b6ea62b600e6049d4cba6466d989098 (diff)
downloadoslo-db-268edcb4e32856ce28db2bc53a9f73e79f9c2daa.tar.gz
Reverse role of synchronous_reader
Repaired the "synchronous_reader" modifier of enginefacade so that it refers to the "writer" engine when set to True, thereby allowing "synchronous" behavior with the writer. When set to False, this is "asynchronous", so this should be associated with the async engines. The flag had the reverse behavior previously. Change-Id: Id7fea7562ba90eb710176d497af103303f230531 Closes-bug: #1746116 (cherry picked from commit 5ca329884d492d78e623e2313142238eb256f1a6)
-rw-r--r--oslo_db/sqlalchemy/enginefacade.py6
-rw-r--r--oslo_db/tests/sqlalchemy/test_enginefacade.py18
-rw-r--r--releasenotes/notes/fix_synchronous_reader-ca442ca9f07470ec.yaml8
3 files changed, 21 insertions, 11 deletions
diff --git a/oslo_db/sqlalchemy/enginefacade.py b/oslo_db/sqlalchemy/enginefacade.py
index 80c320b..1617ebb 100644
--- a/oslo_db/sqlalchemy/enginefacade.py
+++ b/oslo_db/sqlalchemy/enginefacade.py
@@ -393,7 +393,8 @@ class _TransactionFactory(object):
self._start()
if mode is _WRITER:
return self._writer_engine.connect()
- elif self.synchronous_reader or mode is _ASYNC_READER:
+ elif mode is _ASYNC_READER or \
+ (mode is _READER and not self.synchronous_reader):
return self._reader_engine.connect()
else:
return self._writer_engine.connect()
@@ -408,7 +409,8 @@ class _TransactionFactory(object):
kw['bind'] = bind
if mode is _WRITER:
return self._writer_maker(**kw)
- elif self.synchronous_reader or mode is _ASYNC_READER:
+ elif mode is _ASYNC_READER or \
+ (mode is _READER and not self.synchronous_reader):
return self._reader_maker(**kw)
else:
return self._writer_maker(**kw)
diff --git a/oslo_db/tests/sqlalchemy/test_enginefacade.py b/oslo_db/tests/sqlalchemy/test_enginefacade.py
index 8b782a3..e2629ac 100644
--- a/oslo_db/tests/sqlalchemy/test_enginefacade.py
+++ b/oslo_db/tests/sqlalchemy/test_enginefacade.py
@@ -135,15 +135,15 @@ class MockFacadeTest(oslo_test_base.BaseTestCase):
async_reader_maker = writer_maker
if self.synchronous_reader:
- reader_conn = async_reader_conn
- reader_engine = async_reader_engine
- reader_session = async_reader_session
- reader_maker = async_reader_maker
- else:
reader_conn = writer_conn
reader_engine = writer_engine
reader_session = writer_session
reader_maker = writer_maker
+ else:
+ reader_conn = async_reader_conn
+ reader_engine = async_reader_engine
+ reader_session = async_reader_session
+ reader_maker = async_reader_maker
self.connections = AssertDataSource(
writer_conn, reader_conn, async_reader_conn
@@ -236,9 +236,9 @@ class MockFacadeTest(oslo_test_base.BaseTestCase):
async_reader_engine = writer_engine
if self.synchronous_reader:
- reader_engine = async_reader_engine
- else:
reader_engine = writer_engine
+ else:
+ reader_engine = async_reader_engine
engines = AssertDataSource(
writer_engine, reader_engine, async_reader_engine)
@@ -333,9 +333,9 @@ class MockFacadeTest(oslo_test_base.BaseTestCase):
async_reader_maker = writer_maker
if self.synchronous_reader:
- reader_maker = async_reader_maker
- else:
reader_maker = writer_maker
+ else:
+ reader_maker = async_reader_maker
makers = AssertDataSource(
writer_maker,
diff --git a/releasenotes/notes/fix_synchronous_reader-ca442ca9f07470ec.yaml b/releasenotes/notes/fix_synchronous_reader-ca442ca9f07470ec.yaml
new file mode 100644
index 0000000..c842b7d
--- /dev/null
+++ b/releasenotes/notes/fix_synchronous_reader-ca442ca9f07470ec.yaml
@@ -0,0 +1,8 @@
+---
+fixes:
+ - |
+ Repaired the "synchronous_reader" modifier of enginefacade so that it
+ refers to the "writer" engine when set to True, thereby allowing
+ "synchronous" behavior with the writer. When set to False, this is
+ "asynchronous", so this should be associated with the async engines.
+ The flag had the reverse behavior previously.