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
This commit is contained in:
Mike Bayer 2018-01-29 18:25:19 -05:00
parent 650779240e
commit 5ca329884d
3 changed files with 21 additions and 11 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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.