Skip to content

feat: Use multiplexed sessions for read-only transactions #3917

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

Merged
merged 11 commits into from
Jun 23, 2025

Conversation

sakthivelmanii
Copy link
Collaborator

@sakthivelmanii sakthivelmanii commented Jun 17, 2025

Description:

Multi-use and single-use read-only transactions now use a single multiplexed session, instead of a session from the session pool. Multiplexed sessions can handle any number of queries and read-only transactions at the same time.

This change means that the client library will require fewer regular sessions to run the same workload. How much, depends on the distribution of read-only vs read/write transactions that are executed by the application.

Users do not need to take any specific action to re-configure their Spanner client due to this change. However, users who have configured a large number of Min or Max sessions in the session pool due to executing a large number of read-only transactions, could consider whether they can lower this number.

This change does not affect how read/write transactions are executed.

The use of multiplexed sessions can be disabled by setting the environment variable GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS=false.

See https://cloud.google.com/spanner/docs/sessions#multiplexed_sessions for more background information about multiplexed sessions.

@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Jun 17, 2025
Copy link

generated-files-bot bot commented Jun 17, 2025

Warning: This pull request is touching the following templated files:

  • .github/workflows/ci.yaml

@product-auto-label product-auto-label bot added api: spanner Issues related to the googleapis/java-spanner API. size: s Pull request size is small. and removed size: m Pull request size is medium. labels Jun 17, 2025
@sakthivelmanii sakthivelmanii force-pushed the make_mux_session_default branch from 9c195b1 to 6298992 Compare June 17, 2025 10:45
@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. and removed size: s Pull request size is small. labels Jun 17, 2025
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels Jun 18, 2025
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Jun 18, 2025
@sakthivelmanii sakthivelmanii marked this pull request as ready for review June 19, 2025 17:04
@sakthivelmanii sakthivelmanii requested review from a team as code owners June 19, 2025 17:04
rahul2393
rahul2393 previously approved these changes Jun 19, 2025
@harshachinta
Copy link
Contributor

Couple of suggestions - Please ignore if any of these points have already been addressed.

  1. Can we update the PR title to highlight the default behavior of using multiplexed sessions is only for read-only transactions and not for any other transaction types.
  2. With this change, we no longer run integration tests for read-only transactions using regular sessions. Since customers can still disable multiplexed sessions, we may need to continue verifying integration test coverage for the regular session path. Would it make sense to run these tests in continuous or nightly builds to ensure we catch any regressions?
  3. Currently, all client systest configurations use regular sessions, except for one (cloudclientmultiplexedsession), which explicitly enables multiplexed sessions. With this change, all systests will now run read-only transactions using multiplexed sessions. To maintain coverage, we may want to modify or add a lightweight systest that explicitly disables multiplexed sessions for read-only transactions, ensuring the regular session flow is still exercised.
    (Note: Since all client systests are currently disabled due to an ongoing issue, feel free to defer this if needed.)

@sakthivelmanii sakthivelmanii changed the title feat: Enable Multiplex session by default feat: Enable Multiplex session by default for RO transactions Jun 20, 2025
@sakthivelmanii
Copy link
Collaborator Author

@harshachinta Thanks for your inputs.

  1. I have updated it.
  2. Will introduce a new pipeline to run integration tests with regular session as well.
  3. Yes. I am waiting for the issues to be fixed in the systest side. I will ensure all the tests are running with mux session where as one systest is running with regular session

@sakthivelmanii sakthivelmanii changed the title feat: Enable Multiplex session by default for RO transactions feat: Use multiplexed sessions for read-only transactions Jun 20, 2025
@sakthivelmanii sakthivelmanii merged commit 37fdc27 into main Jun 23, 2025
42 checks passed
@sakthivelmanii sakthivelmanii deleted the make_mux_session_default branch June 23, 2025 08:56
svc-squareup-copybara pushed a commit to cashapp/misk that referenced this pull request Jun 30, 2025
| Package | Type | Package file | Manager | Update | Change |
|---|---|---|---|---|---|
|
[com.google.cloud:google-cloud-spanner](https://github.com/googleapis/java-spanner)
| dependencies | misk/gradle/libs.versions.toml | gradle | minor |
`6.95.1` -> `6.96.0` |
|
[com.google.cloud:google-cloud-datastore](https://github.com/googleapis/java-datastore)
| dependencies | misk/gradle/libs.versions.toml | gradle | minor |
`2.29.2` -> `2.30.0` |
|
[com.squareup.okio:okio-fakefilesystem](https://github.com/square/okio)
| dependencies | misk/gradle/libs.versions.toml | gradle | minor |
`3.13.0` -> `3.14.0` |
| [com.squareup.okio:okio](https://github.com/square/okio) |
dependencies | misk/gradle/libs.versions.toml | gradle | minor |
`3.13.0` -> `3.14.0` |
| [com.datadoghq:dd-trace-api](https://github.com/datadog/dd-trace-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`1.50.0` -> `1.50.1` |
| [software.amazon.awssdk:sdk-core](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.71` -> `2.31.73` |
| [software.amazon.awssdk:sqs](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.71` -> `2.31.73` |
|
[software.amazon.awssdk:dynamodb-enhanced](https://aws.amazon.com/sdkforjava)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.71` -> `2.31.73` |
| [software.amazon.awssdk:dynamodb](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.71` -> `2.31.73` |
| [software.amazon.awssdk:aws-core](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.71` -> `2.31.73` |
| [software.amazon.awssdk:bom](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.71` -> `2.31.73` |
| [software.amazon.awssdk:auth](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.71` -> `2.31.73` |

---

### Release Notes

<details>
<summary>googleapis/java-spanner
(com.google.cloud:google-cloud-spanner)</summary>

###
[`v6.96.0`](https://github.com/googleapis/java-spanner/blob/HEAD/CHANGELOG.md#6960-2025-06-27)

##### Features

- Allow JDBC to configure directpath for connection
([#&#8203;3929](googleapis/java-spanner#3929))
([d754f1f](googleapis/java-spanner@d754f1f))
- Support getOrNull and getOrDefault in Struct
([#&#8203;3914](googleapis/java-spanner#3914))
([1dc5a3e](googleapis/java-spanner@1dc5a3e))
- Use multiplexed sessions for read-only transactions
([#&#8203;3917](googleapis/java-spanner#3917))
([37fdc27](googleapis/java-spanner@37fdc27))

##### Bug Fixes

- Allow zero durations to be set for connections
([#&#8203;3916](googleapis/java-spanner#3916))
([43ea4fa](googleapis/java-spanner@43ea4fa))

##### Documentation

- Add snippet for Repeatable Read configuration at client and
transaction
([#&#8203;3908](googleapis/java-spanner#3908))
([ff3d212](googleapis/java-spanner@ff3d212))
- Update SpannerSample.java to align with best practices
([#&#8203;3625](googleapis/java-spanner#3625))
([7bfc62d](googleapis/java-spanner@7bfc62d))

</details>

<details>
<summary>googleapis/java-datastore
(com.google.cloud:google-cloud-datastore)</summary>

###
[`v2.30.0`](https://github.com/googleapis/java-datastore/blob/HEAD/CHANGELOG.md#2300-2025-06-26)

##### Features

- Enable grpc configurator for client-side tracing
([#&#8203;1886](googleapis/java-datastore#1886))
([97004c8](googleapis/java-datastore@97004c8))

##### Dependencies

- Update dependency com.google.cloud:gapic-libraries-bom to v1.60.0
([#&#8203;1799](googleapis/java-datastore#1799))
([bf2a33c](googleapis/java-datastore@bf2a33c))
- Update dependency com.google.cloud:sdk-platform-java-config to v3.50.0
([#&#8203;1897](googleapis/java-datastore#1897))
([a8d99cd](googleapis/java-datastore@a8d99cd))
- Update googleapis/sdk-platform-java action to v2.59.1
([#&#8203;1880](googleapis/java-datastore#1880))
([4fb9929](googleapis/java-datastore@4fb9929))
- Update googleapis/sdk-platform-java action to v2.60.0
([#&#8203;1898](googleapis/java-datastore#1898))
([0921f86](googleapis/java-datastore@0921f86))

</details>

<details>
<summary>square/okio (com.squareup.okio:okio-fakefilesystem)</summary>

###
[`v3.14.0`](https://github.com/square/okio/blob/HEAD/CHANGELOG.md#Version-3140)

*2025-06-28*

- Upgrade: \[kotlinx-datetime 0.7.0]\[datetime\_0\_7\_0]. This impacts
the `okio-fakefilesystem`
artifact only. This is a binary-incompatible backwards-incompatible
change that cannot co-exist
with previous releases of `okio-fakefilesystem`! If you observe a
`NoSuchMethodError` calling
`FakeFileSystem.init`, update the calling code to this release (or
newer) and recompile. We don't
like imposing backwards-incompatible changes like this on you and do so
regretfully.

</details>

<details>
<summary>datadog/dd-trace-java (com.datadoghq:dd-trace-api)</summary>

###
[`v1.50.1`](https://github.com/DataDog/dd-trace-java/releases/tag/v1.50.1):
1.50.1

### Components

#### Build & Tooling

- ✨ Migrate publishing to Maven Central Portal
([#&#8203;9054](DataDog/dd-trace-java#9054) -
[@&#8203;sarahchen6](https://github.com/sarahchen6))

#### Trace context propagation

- 🐛 Drop Baggage when `TracePropagationBehaviorExtract=IGNORE`
([#&#8203;9052](DataDog/dd-trace-java#9052) -
[@&#8203;mhlidd](https://github.com/mhlidd))

#### Tracer public API

- 🐛 Fix ArrayIndexOutOfBoundsException in PercentEscaper
([#&#8203;9050](DataDog/dd-trace-java#9050) -
[@&#8203;mhlidd](https://github.com/mhlidd))

### Instrumentations

#### Akka instrumentation

- 🐛 Fix NPE in akka-http and pekko-http integrations
([#&#8203;9049](DataDog/dd-trace-java#9049) -
[@&#8203;mcculls](https://github.com/mcculls))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 6pm every weekday,before 2am
every weekday" in timezone Australia/Melbourne, Automerge - At any time
(no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://github.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://github.com/renovatebot/renovate).

GitOrigin-RevId: e80867de3af2534eca79fe17a33f5c76801bcd6a
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: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants