summaryrefslogtreecommitdiff
path: root/oslo_db
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-01-29 18:25:19 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2018-01-29 18:25:19 -0500
commit5ca329884d492d78e623e2313142238eb256f1a6 (patch)
tree5e2fff0ff5d98ebce0c662bd7f0424238369e481 /oslo_db
parent650779240e69d36b0f95969fd689bfa52dd80c73 (diff)
downloadoslo-db-5ca329884d492d78e623e2313142238eb256f1a6.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
Diffstat (limited to 'oslo_db')
-rw-r--r--oslo_db/sqlalchemy/enginefacade.py6
-rw-r--r--oslo_db/tests/sqlalchemy/test_enginefacade.py18
2 files changed, 13 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 91e40a1..b085f91 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,