Skip to content

Conversation

@harshachinta
Copy link
Contributor

@harshachinta harshachinta commented Oct 30, 2024

The following information apply only if:

  1. The application using the Java client library enables read-write multiplexed sessions via an environment variable.
  2. The JDBC driver enables multiplexed sessions for read-write transactions by default.

On the backend, a server-side switch controls whether read-write transactions on multiplexed sessions are enabled. If this switch is disabled, all read-write transactions on multiplexed sessions will fail with UNIMPLEMENTED errors. This scenario is handled in the Java Spanner client as follows:

  1. When the server-side switch is OFF before application start:
    a. When the application starts, the Spanner client library asynchronously creates a multiplexed session.
    b. After creating the multiplexed session, an asynchronous BeginTransaction RPC is explicitly invoked on a read-write transaction. If this call fails with an UNIMPLEMENTED error, the client disables read-write transactions on multiplexed sessions.
    c. From this point, all new read-write transactions will fall back to regular sessions. However, any read-write transactions that started before this process completes will fail with an UNIMPLEMENTED error.

  2. When the server-side switch is turned OFF at time t1 after the application has started at t0 (where t0 < t1):
    a. If a read-write transaction fails with an UNIMPLEMENTED error, the Spanner client records this information and fails the transaction.
    b. All subsequent read-write transactions then automatically fall back to regular sessions.

Note: This does not impact the behavior of read-only transactions on multiplexed sessions.

@harshachinta harshachinta requested a review from a team as a code owner October 30, 2024 13:03
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/java-spanner API. labels Oct 30, 2024
@harshachinta harshachinta merged commit 07b777d into googleapis:main Nov 5, 2024
31 checks passed
sakthivelmanii pushed a commit to sakthivelmanii/java-spanner that referenced this pull request Nov 7, 2024
…sions (googleapis#3441)

* chore(spanner): handle server side kill switch for multiplexed sessions with read-write

* chore(spanner): lint fix

* chore(spanner): add error message

* chore(spanner): fix unit tests due to backgroung BeginTransaction RPC

* chore(spanner): lint fix

* chore(spanner): handle mock spanner logic

* chore(spanner): testcase fix

* chore(spanner): do not register backgroung begin txn in mock spanner

* chore(spanner): revert unit test changes

* chore(spanner): verify error message of the exeception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/java-spanner API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants