Skip to content

feat(spanner): support for Multiplexed Session Partitioned Ops #2252

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 6 commits into from
Mar 27, 2025

Conversation

alkatrivedi
Copy link
Contributor

@alkatrivedi alkatrivedi commented Mar 20, 2025

This PR contains code changes to add support for multiplexed session support in Partitioned DML transactions.

@alkatrivedi alkatrivedi requested review from a team as code owners March 20, 2025 10:03
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/nodejs-spanner API. labels Mar 20, 2025
@alkatrivedi alkatrivedi force-pushed the mux-session-support-partitioned-ops branch from 6d5da0b to f163bb1 Compare March 20, 2025 10:47
@alkatrivedi alkatrivedi marked this pull request as draft March 20, 2025 10:50
This PR contains code changes to add support for option IsolationLevel at the client level and at the transaction level.
supported methods are(RW and Blind Write):

```
- writeAtLeastOnce
- runTransactionAsync
- runTransaction
- getTransaction
- async getTransaction(from transaction runner class)
```
@alkatrivedi alkatrivedi force-pushed the mux-session-support-partitioned-ops branch from d16e367 to 433a20a Compare March 20, 2025 13:23
@alkatrivedi alkatrivedi force-pushed the mux-session-support-partitioned-ops branch 2 times, most recently from 4803966 to 32ccb88 Compare March 20, 2025 13:56
@alkatrivedi alkatrivedi force-pushed the mux-session-support-partitioned-ops branch from 32ccb88 to 0176e8f Compare March 21, 2025 04:58
Copy link

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

  • .kokoro/presubmit/node14/system-test-multiplexed-session.cfg - .kokoro files are templated and should be updated in synthtool
  • .kokoro/trampoline_v2.sh - .kokoro files are templated and should be updated in synthtool

@alkatrivedi alkatrivedi added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Mar 24, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 24, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 24, 2025
@alkatrivedi alkatrivedi force-pushed the mux-session-support-partitioned-ops branch 6 times, most recently from a0e46ff to 0683469 Compare March 24, 2025 13:57
@alkatrivedi alkatrivedi marked this pull request as ready for review March 24, 2025 13:58
@@ -117,6 +126,12 @@ export class SessionFactory
process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS === 'true'
? (this.isMultiplexed = true)
: (this.isMultiplexed = false);
// set the isMultiplexedPartitionedOps property to true if multiplexed session is enabled for paritioned ops, otherwise set the property to false
process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS === 'true' &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isMultiplexedPartitionOps = process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS === 'true' && process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_PARTITIONED_OPS === 'true'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@alkatrivedi alkatrivedi force-pushed the mux-session-support-partitioned-ops branch from 0683469 to 312504c Compare March 25, 2025 11:00
@alkatrivedi alkatrivedi added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 25, 2025
@alkatrivedi alkatrivedi added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 25, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 25, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 25, 2025
* If multiplexed sessions are enabled for partitioned ops this methods delegates the request to `getSession()`, which will return
* either a multiplexed session or a regular session based on the configuration.
*
* If the multiplexed sessions are not enabled, a session is retrieved from the regular session pool.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* If the multiplexed sessions are not enabled, a session is retrieved from the regular session pool.
* If the multiplexed sessions are disabled, a session is retrieved from the regular session pool.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -143,6 +157,23 @@ export class SessionFactory
);
}

/**
* Retrieves a session for partitioned operations, selecting the appropriate session type
* based on whether multiplexed sessions are enabled for partitioned operations.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* based on whether multiplexed sessions are enabled for partitioned operations.
* based on whether multiplexed sessions are enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* Retrieves a session for partitioned operations, selecting the appropriate session type
* based on whether multiplexed sessions are enabled for partitioned operations.
*
* If multiplexed sessions are enabled for partitioned ops this methods delegates the request to `getSession()`, which will return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* If multiplexed sessions are enabled for partitioned ops this methods delegates the request to `getSession()`, which will return
* If multiplexed sessions are enabled for partitioned ops this methods delegates the request to `getSession()`, which returns

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -165,7 +198,7 @@ export class SessionFactory
* @throws {Error} If the session is invalid or cannot be released.
*/
release(session: Session): void {
if (!this.isMultiplexed) {
if (!session.metadata.multiplexed) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need optional check for "metadata" here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made it optional

});
muxEnabled.forEach(isMuxEnabled => {
describe(
'when GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS is ' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'when GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS is ' +
'when GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_PARTITIONED_OPS is ' +

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@@ -342,10 +342,14 @@ export class MockSpanner {
* Creates a new session for the given database and adds it to the map of sessions of this server.
* @param database The database to create the session for.
*/
private newSession(database: string): protobuf.Session {
private newSession(multiplexed: boolean, database: string): protobuf.Session {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add multiplexed: boolean as an optional parameter, with default value as false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -445,8 +449,9 @@ export class MockSpanner {
this.simulateExecutionTime(this.batchCreateSessions.name)
.then(() => {
const sessions = new Array<protobuf.Session>();
const multiplexed = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should not be required once you make multiplexed as optional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, updated. thanks for the suggestion!

@alkatrivedi alkatrivedi force-pushed the mux-session-support-partitioned-ops branch from 312504c to 1014985 Compare March 26, 2025 11:13
@alkatrivedi alkatrivedi added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Mar 26, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 26, 2025
@alkatrivedi alkatrivedi force-pushed the mux-session-support-partitioned-ops branch from 1014985 to d26c69a Compare March 26, 2025 13:45
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 26, 2025
@alkatrivedi alkatrivedi merged commit e7ce471 into main Mar 27, 2025
21 checks passed
@alkatrivedi alkatrivedi deleted the mux-session-support-partitioned-ops branch March 27, 2025 04:52
alkatrivedi added a commit that referenced this pull request Apr 14, 2025
* feat(spanner): support for Multiplexed Session Partitioned Ops

* feat(spanner): add support for snapshot isolation (#2245)

This PR contains code changes to add support for option IsolationLevel at the client level and at the transaction level.
supported methods are(RW and Blind Write):

```
- writeAtLeastOnce
- runTransactionAsync
- runTransaction
- getTransaction
- async getTransaction(from transaction runner class)
```

* refactor

* refactor
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/nodejs-spanner API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants