Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add opt-in for using multiplexed sessions for blind writes #3540

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions google-cloud-spanner-executor/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@
<method>CloudExecutorImpl(boolean)</method>
<to>CloudExecutorImpl(boolean, double)</to>
</difference>
<difference>
<differenceType>7002</differenceType>
<className>com/google/cloud/spanner/SessionPoolOptionsHelper</className>
<method>com.google.cloud.spanner.SessionPoolOptions$Builder setUseMultiplexedSessionBlindWrite(com.google.cloud.spanner.SessionPoolOptions$Builder, boolean)</method>
</difference>
</differences>
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,6 @@ private synchronized Spanner getClient(long timeoutSeconds, boolean useMultiplex
com.google.cloud.spanner.SessionPoolOptions.Builder poolOptionsBuilder =
com.google.cloud.spanner.SessionPoolOptions.newBuilder();
SessionPoolOptionsHelper.setUseMultiplexedSession(poolOptionsBuilder, useMultiplexedSession);
SessionPoolOptionsHelper.setUseMultiplexedSessionBlindWrite(
poolOptionsBuilder, useMultiplexedSession);
SessionPoolOptionsHelper.setUseMultiplexedSessionForRW(
poolOptionsBuilder, useMultiplexedSession);
LOGGER.log(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ public static SessionPoolOptions.Builder setUseMultiplexedSession(
return sessionPoolOptionsBuilder.setUseMultiplexedSession(useMultiplexedSession);
}

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

// TODO: Remove when multiplexed session for read write is released.
public static SessionPoolOptions.Builder setUseMultiplexedSessionForRW(
SessionPoolOptions.Builder sessionPoolOptionsBuilder, boolean useMultiplexedSessionForRW) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ public class SessionPoolOptions {

private final boolean useMultiplexedSession;

/**
* Controls whether multiplexed session is enabled for blind write or not. This is only used for
* systest soak. TODO: Remove when multiplexed session for blind write is released.
*/
private final boolean useMultiplexedSessionBlindWrite;

private final boolean useMultiplexedSessionForRW;

private final boolean useMultiplexedSessionForPartitionedOps;
Expand Down Expand Up @@ -122,7 +116,6 @@ private SessionPoolOptions(Builder builder) {
(useMultiplexedSessionFromEnvVariable != null)
? useMultiplexedSessionFromEnvVariable
: builder.useMultiplexedSession;
this.useMultiplexedSessionBlindWrite = builder.useMultiplexedSessionBlindWrite;
// useMultiplexedSessionForRW priority => Environment var > private setter > client default
Boolean useMultiplexedSessionForRWFromEnvVariable =
getUseMultiplexedSessionForRWFromEnvVariable();
Expand Down Expand Up @@ -205,7 +198,6 @@ public int hashCode() {
this.inactiveTransactionRemovalOptions,
this.poolMaintainerClock,
this.useMultiplexedSession,
this.useMultiplexedSessionBlindWrite,
this.useMultiplexedSessionForRW,
this.multiplexedSessionMaintenanceDuration);
}
Expand Down Expand Up @@ -349,7 +341,7 @@ public boolean getUseMultiplexedSession() {
@VisibleForTesting
@InternalApi
protected boolean getUseMultiplexedSessionBlindWrite() {
return getUseMultiplexedSession() && useMultiplexedSessionBlindWrite;
return getUseMultiplexedSession();
}

@VisibleForTesting
Expand Down Expand Up @@ -601,9 +593,6 @@ public static class Builder {
// Set useMultiplexedSession to true to make multiplexed session the default.
private boolean useMultiplexedSession = false;

// TODO: Remove when multiplexed session for blind write is released.
private boolean useMultiplexedSessionBlindWrite = false;

// This field controls the default behavior of session management for RW operations in Java
// client.
// Set useMultiplexedSessionForRW to true to make multiplexed session for RW operations the
Expand Down Expand Up @@ -657,7 +646,6 @@ private Builder(SessionPoolOptions options) {
this.randomizePositionQPSThreshold = options.randomizePositionQPSThreshold;
this.inactiveTransactionRemovalOptions = options.inactiveTransactionRemovalOptions;
this.useMultiplexedSession = options.useMultiplexedSession;
this.useMultiplexedSessionBlindWrite = options.useMultiplexedSessionBlindWrite;
this.useMultiplexedSessionForRW = options.useMultiplexedSessionForRW;
this.useMultiplexedSessionPartitionedOps = options.useMultiplexedSessionForPartitionedOps;
this.multiplexedSessionMaintenanceDuration = options.multiplexedSessionMaintenanceDuration;
Expand Down Expand Up @@ -857,17 +845,6 @@ Builder setUseMultiplexedSession(boolean useMultiplexedSession) {
return this;
}

/**
* This method enables multiplexed sessions for blind writes. This method will be removed in the
* future when multiplexed sessions has been made the default for all operations.
*/
@InternalApi
@VisibleForTesting
Builder setUseMultiplexedSessionBlindWrite(boolean useMultiplexedSessionBlindWrite) {
this.useMultiplexedSessionBlindWrite = useMultiplexedSessionBlindWrite;
return this;
}

/**
* Sets whether the client should use multiplexed session for R/W operations or not. This method
* is intentionally package-private and intended for internal use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public void createSpannerInstance() {
.setSessionPoolOption(
SessionPoolOptions.newBuilder()
.setUseMultiplexedSession(true)
.setUseMultiplexedSessionBlindWrite(true)
.setUseMultiplexedSessionForRW(true)
.setUseMultiplexedSessionPartitionedOps(true)
// Set the maintainer to loop once every 1ms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,9 @@ public void write() throws InterruptedException {

@Test
public void writeAtLeastOnce() throws InterruptedException {
assumeFalse(
"Multiplexed session do not throw a SessionNotFound errors. ",
spanner.getOptions().getSessionPoolOptions().getUseMultiplexedSession());
assertThrowsSessionNotFoundIfShouldFail(
() ->
client.writeAtLeastOnce(
Expand Down
Loading