Skip to content

Commit

Permalink
chore(spanner): support multiplexed session for rw transactions in ex… (
Browse files Browse the repository at this point in the history
#3471)

* chore(spanner): support multiplexed session for rw transactions in executor

* chore(spanner): lint fix
  • Loading branch information
harshachinta authored Dec 6, 2024
1 parent 8a7d533 commit 1234447
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,15 @@ private synchronized Spanner getClient(long timeoutSeconds, boolean useMultiplex

com.google.cloud.spanner.SessionPoolOptions.Builder poolOptionsBuilder =
com.google.cloud.spanner.SessionPoolOptions.newBuilder();
SessionPoolOptionsHelper.setUseMultiplexedSession(
com.google.cloud.spanner.SessionPoolOptions.newBuilder(), useMultiplexedSession);
SessionPoolOptionsHelper.setUseMultiplexedSession(poolOptionsBuilder, useMultiplexedSession);
SessionPoolOptionsHelper.setUseMultiplexedSessionBlindWrite(
com.google.cloud.spanner.SessionPoolOptions.newBuilder(), useMultiplexedSession);
poolOptionsBuilder, useMultiplexedSession);
SessionPoolOptionsHelper.setUseMultiplexedSessionForRW(
poolOptionsBuilder, useMultiplexedSession);
LOGGER.log(
Level.INFO,
String.format(
"Using multiplexed sessions for read-write transactions: %s", useMultiplexedSession));
com.google.cloud.spanner.SessionPoolOptions sessionPoolOptions = poolOptionsBuilder.build();
// Cloud Spanner Client does not support global retry settings,
// Thus, we need to add retry settings to each individual stub.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ public static SessionPoolOptions.Builder setUseMultiplexedSessionBlindWrite(
return sessionPoolOptionsBuilder.setUseMultiplexedSessionBlindWrite(
useMultiplexedSessionBlindWrite);
}

// TODO: Remove when multiplexed session for read write is released.
public static SessionPoolOptions.Builder setUseMultiplexedSessionForRW(
SessionPoolOptions.Builder sessionPoolOptionsBuilder, boolean useMultiplexedSessionForRW) {
return sessionPoolOptionsBuilder.setUseMultiplexedSessionForRW(useMultiplexedSessionForRW);
}
}

0 comments on commit 1234447

Please sign in to comment.