@@ -36,26 +36,29 @@ class DatabaseClientImpl implements DatabaseClient {
3636 @ VisibleForTesting final String clientId ;
3737 @ VisibleForTesting final SessionPool pool ;
3838 @ VisibleForTesting final MultiplexedSessionDatabaseClient multiplexedSessionDatabaseClient ;
39+ @ VisibleForTesting final boolean useMultiplexedSessionForRW ;
3940
4041 @ VisibleForTesting
4142 DatabaseClientImpl (SessionPool pool , TraceWrapper tracer ) {
42- this ("" , pool , /* multiplexedSessionDatabaseClient = */ null , tracer );
43+ this ("" , pool , /* multiplexedSessionDatabaseClient = */ null , tracer , false );
4344 }
4445
4546 @ VisibleForTesting
4647 DatabaseClientImpl (String clientId , SessionPool pool , TraceWrapper tracer ) {
47- this (clientId , pool , /* multiplexedSessionDatabaseClient = */ null , tracer );
48+ this (clientId , pool , /* multiplexedSessionDatabaseClient = */ null , tracer , false );
4849 }
4950
5051 DatabaseClientImpl (
5152 String clientId ,
5253 SessionPool pool ,
5354 @ Nullable MultiplexedSessionDatabaseClient multiplexedSessionDatabaseClient ,
54- TraceWrapper tracer ) {
55+ TraceWrapper tracer ,
56+ boolean useMultiplexedSessionForRW ) {
5557 this .clientId = clientId ;
5658 this .pool = pool ;
5759 this .multiplexedSessionDatabaseClient = multiplexedSessionDatabaseClient ;
5860 this .tracer = tracer ;
61+ this .useMultiplexedSessionForRW = useMultiplexedSessionForRW ;
5962 }
6063
6164 @ VisibleForTesting
@@ -72,6 +75,14 @@ DatabaseClient getMultiplexedSession() {
7275 return pool .getMultiplexedSessionWithFallback ();
7376 }
7477
78+ @ VisibleForTesting
79+ DatabaseClient getMultiplexedSessionForRW () {
80+ if (this .useMultiplexedSessionForRW ) {
81+ return getMultiplexedSession ();
82+ }
83+ return getSession ();
84+ }
85+
7586 @ Override
7687 public Dialect getDialect () {
7788 return pool .getDialect ();
@@ -215,7 +226,7 @@ public ReadOnlyTransaction readOnlyTransaction(TimestampBound bound) {
215226 public TransactionRunner readWriteTransaction (TransactionOption ... options ) {
216227 ISpan span = tracer .spanBuilder (READ_WRITE_TRANSACTION , options );
217228 try (IScope s = tracer .withSpan (span )) {
218- return getSession ().readWriteTransaction (options );
229+ return getMultiplexedSessionForRW ().readWriteTransaction (options );
219230 } catch (RuntimeException e ) {
220231 span .setStatus (e );
221232 span .end ();
0 commit comments