Skip to content

chore(x-goog-spanner-request-id): add SessionImpl.getChannel() and Options.RequestIdOption.(equals, hashCode) #3900

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

Conversation

odeke-em
Copy link
Contributor

@odeke-em odeke-em commented Jun 3, 2025

Implements channelId retrieval that'll then be used to plumb into x-goog-spanner-request-id's channel.

Fixes #3899

@odeke-em odeke-em requested review from a team as code owners June 3, 2025 04:44
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: spanner Issues related to the googleapis/java-spanner API. labels Jun 3, 2025
@olavloite olavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 4, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 4, 2025
@odeke-em odeke-em force-pushed the x-goog-spanner-request-id-SessionImpl.getChannel branch from f1c4977 to 6da90d0 Compare June 4, 2025 23:46
@odeke-em odeke-em changed the title chore(x-goog-spanner-request-id): add SessionImpl.getChannel() chore(x-goog-spanner-request-id): add SessionImpl.getChannel() and Options.RequestIdOption.(equals, hashCode) Jun 4, 2025
@odeke-em odeke-em force-pushed the x-goog-spanner-request-id-SessionImpl.getChannel branch from 6da90d0 to c822be3 Compare June 4, 2025 23:48
@odeke-em odeke-em force-pushed the x-goog-spanner-request-id-SessionImpl.getChannel branch 2 times, most recently from 4f13b14 to 21f755e Compare June 11, 2025 15:15
@olavloite olavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 11, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 11, 2025
@odeke-em odeke-em force-pushed the x-goog-spanner-request-id-SessionImpl.getChannel branch from 21f755e to cad7fa9 Compare June 12, 2025 08:11
@olavloite olavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 13, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 13, 2025
odeke-em added 2 commits June 18, 2025 22:44
…tions.RequestIdOption.(equals, hashCode)

Implements channelId retrieval that'll then be used to
plumb into x-goog-spanner-request-id's channel. Also implements
Options.RequestIdOption.(equals, hashCode)

Fixes googleapis#3899

Implement Options.RequestIdOption.(equals, hashCode)
@rahul2393 rahul2393 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 19, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 19, 2025
@odeke-em odeke-em force-pushed the x-goog-spanner-request-id-SessionImpl.getChannel branch from e96ae47 to 6e65c3e Compare June 19, 2025 04:56
@rahul2393 rahul2393 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 19, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 19, 2025
Comment on lines +1101 to +1104
if (this.reqId == null || other.reqId == null) {
return this.reqId == null && other.reqId == null;
}
return this.reqId.equals(other.reqId);
Copy link
Collaborator

Choose a reason for hiding this comment

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

tip for next time (just leave as-is for now);Java has a utility method for this:

java.util.Objects.equals(this.reqId, other.reqId);

@@ -464,17 +464,15 @@ public AsyncTransactionManagerImpl transactionManagerAsync(TransactionOption...

@Override
public ApiFuture<Empty> asyncClose() {
XGoogSpannerRequestId reqId =
this.getRequestIdCreator().nextRequestId(1 /* TODO: channelId */, 0);
XGoogSpannerRequestId reqId = this.getRequestIdCreator().nextRequestId(this.getChannel(), 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the initial attempt 0 here and in the close() method, but 1 in beginTransactionAsync()?

Comment on lines +599 to +601
if (getIsMultiplexed()) {
return 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume that this means that we will be getting the channel that is being used in a different way for multiplexed sessions, and that this method is only intended for actual use with regular sessions.

@olavloite olavloite merged commit db0ed07 into googleapis:main Jun 20, 2025
30 of 36 checks passed
@odeke-em odeke-em deleted the x-goog-spanner-request-id-SessionImpl.getChannel branch June 20, 2025 04:55
odeke-em added a commit to odeke-em/java-spanner that referenced this pull request Jun 20, 2025
odeke-em added a commit to odeke-em/java-spanner that referenced this pull request Jun 22, 2025
…s prior code review suggestions

This change propagates the associated request-id into encountered
exceptions and also addresses some code review questions from PR googleapis#3900.
While here added some updates for AbstractReadContext.java and
ResumableStreamIterator.java to set grounds for much smaller PRs
in which we shall wholesomely test the changes.

Curved out of PR googleapis#3898 and PR googleapis#3915
odeke-em added a commit to odeke-em/java-spanner that referenced this pull request Jun 22, 2025
…s prior code review suggestions

This change propagates the associated request-id into encountered
exceptions and also addresses some code review questions from PR googleapis#3900.
While here added some updates for AbstractReadContext.java and
ResumableStreamIterator.java to set grounds for much smaller PRs
in which we shall wholesomely test the changes.

Curved out of PR googleapis#3898 and PR googleapis#3915
odeke-em added a commit to odeke-em/java-spanner that referenced this pull request Jun 23, 2025
…s prior code review suggestions

This change propagates the associated request-id into encountered
exceptions and also addresses some code review questions from PR googleapis#3900.
While here added some updates for AbstractReadContext.java and
ResumableStreamIterator.java to set grounds for much smaller PRs
in which we shall wholesomely test the changes.

Curved out of PR googleapis#3898 and PR googleapis#3915
odeke-em added a commit to odeke-em/java-spanner that referenced this pull request Jun 23, 2025
…s prior code review suggestions

This change propagates the associated request-id into encountered
exceptions and also addresses some code review questions from PR googleapis#3900.
While here added some updates for AbstractReadContext.java and
ResumableStreamIterator.java to set grounds for much smaller PRs
in which we shall wholesomely test the changes.

Curved out of PR googleapis#3898 and PR googleapis#3915
odeke-em added a commit to odeke-em/java-spanner that referenced this pull request Jun 26, 2025
…s prior code review suggestions

This change propagates the associated request-id into encountered
exceptions and also addresses some code review questions from PR googleapis#3900.
While here added some updates for AbstractReadContext.java and
ResumableStreamIterator.java to set grounds for much smaller PRs
in which we shall wholesomely test the changes.

Curved out of PR googleapis#3898 and PR googleapis#3915
olavloite pushed a commit that referenced this pull request Jun 27, 2025
…s prior code review suggestions (#3922)

* chore(x-goog-spanner-request-id): propagate reqId into exceptions plus prior code review suggestions

This change propagates the associated request-id into encountered
exceptions and also addresses some code review questions from PR #3900.
While here added some updates for AbstractReadContext.java and
ResumableStreamIterator.java to set grounds for much smaller PRs
in which we shall wholesomely test the changes.

Curved out of PR #3898 and PR #3915

* Update tests with session.getRequestIdCreator

* More plumbing

* Update tests

* Deal with the multiplex-session .getOptions null returns in getChannel

* Correct array copy
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: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x-goog-spanner-request-id: for DatabaseClientImpl and all session users, infer channelId
4 participants