Skip to content

chore: update executor to fix a SI issue#13492

Open
gyang-google wants to merge 1 commit into
googleapis:mainfrom
gyang-google:patch-1
Open

chore: update executor to fix a SI issue#13492
gyang-google wants to merge 1 commit into
googleapis:mainfrom
gyang-google:patch-1

Conversation

@gyang-google

Copy link
Copy Markdown
Contributor

No description provided.

@gyang-google gyang-google requested review from a team as code owners June 16, 2026 05:00

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the transaction lock mode configuration in CloudClientExecutor.java based on repeatableRead and optimistic flags. The reviewer pointed out that since PESSIMISTIC is the default lock mode in Spanner, the logic can be simplified to only explicitly set the OPTIMISTIC lock mode when necessary, and provided a code suggestion to achieve this.

Comment on lines +400 to 405
if (!repeatableRead && optimistic) {
transactionOptions.add(Options.readLockMode(ReadLockMode.OPTIMISTIC));
} else {
}
if (repeatableRead && !optimistic) {
transactionOptions.add(Options.readLockMode(ReadLockMode.PESSIMISTIC));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The logic for setting the transaction lock mode can be simplified. The default lock mode for read-write transactions in Spanner is PESSIMISTIC. Therefore, you only need to explicitly set the lock mode when OPTIMISTIC is required.

The current implementation has a redundant condition that explicitly sets the PESSIMISTIC lock mode, which is already the default.

You can simplify this block to a single if statement that handles the OPTIMISTIC case, making the code more concise and readable.

Suggested change
if (!repeatableRead && optimistic) {
transactionOptions.add(Options.readLockMode(ReadLockMode.OPTIMISTIC));
} else {
}
if (repeatableRead && !optimistic) {
transactionOptions.add(Options.readLockMode(ReadLockMode.PESSIMISTIC));
}
if (optimistic && !repeatableRead) {
transactionOptions.add(Options.readLockMode(ReadLockMode.OPTIMISTIC));
}

@sakthivelmanii sakthivelmanii added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 16, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants