Skip to content
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

feat(spanner): add x-goog-spanner-route-to-leader header to Spanner RPC contexts for RW/PDML transactions. #7500

Merged
merged 6 commits into from
Mar 3, 2023

Conversation

rahul2393
Copy link
Contributor

The header is added to support leader-aware-routing feature, which aims at reducing cross-regional latency for RW/PDML transactions in a multi-region instance.

@rahul2393 rahul2393 requested review from a team as code owners March 1, 2023 10:09
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Mar 1, 2023
@rahul2393 rahul2393 requested a review from olavloite March 1, 2023 10:09
@rahul2393 rahul2393 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 1, 2023
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 1, 2023
@codyoss codyoss changed the title feat: add x-goog-spanner-route-to-leader header to Spanner RPC contexts for RW/PDML transactions. feat(spanner): add x-goog-spanner-route-to-leader header to Spanner RPC contexts for RW/PDML transactions. Mar 1, 2023
spanner/pdml.go Show resolved Hide resolved
@@ -1676,7 +1681,7 @@ func (t *writeOnlyTransaction) applyAtLeastOnce(ctx context.Context, ms ...*Muta
return ToSpannerError(err)
}
}
res, err := sh.getClient().Commit(contextWithOutgoingMetadata(ctx, sh.getMetadata()), &sppb.CommitRequest{
res, err := sh.getClient().Commit(contextWithOutgoingMetadata(ctx, sh.getMetadata(), false), &sppb.CommitRequest{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this never using routeToLeader? Would it not make sense to make this use the client setting, as it is a read/write transaction?

// need to be routed to the leader region.
//
// Default: true
RouteToLeader bool
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that we need to invert this to DisableRouteToLeader with a default false value. The problem now is that anyone who is currently using NewClientWithConfig(ClientConfig{ .... }) will create a config with RouteToLeader=false, unless they change their code after this change. We want this option to be enabled by default, but in the current setup, it won't be for anyone who does not use the config-less NewClient(...) method.

@rahul2393 rahul2393 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 2, 2023
@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Mar 2, 2023
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 3, 2023
@@ -1676,7 +1681,7 @@ func (t *writeOnlyTransaction) applyAtLeastOnce(ctx context.Context, ms ...*Muta
return ToSpannerError(err)
}
}
res, err := sh.getClient().Commit(contextWithOutgoingMetadata(ctx, sh.getMetadata()), &sppb.CommitRequest{
res, err := sh.getClient().Commit(contextWithOutgoingMetadata(ctx, sh.getMetadata(), true), &sppb.CommitRequest{
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this just use the client setting for disableRouteToLeader?

If not: It is a read/write transaction, so shouldn't the default then be 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.

Thanks, fixed

@rahul2393 rahul2393 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 3, 2023
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 3, 2023
@rahul2393 rahul2393 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 3, 2023
@rahul2393 rahul2393 merged commit fcab05f into main Mar 3, 2023
@rahul2393 rahul2393 deleted the lar branch March 3, 2023 20:49
@rahul2393 rahul2393 restored the lar branch March 6, 2023 05:24
rahul2393 added a commit that referenced this pull request Mar 6, 2023
…panner RPC contexts for RW/PDML transactions. (#7500)"

This reverts commit fcab05f.
@rahul2393 rahul2393 deleted the lar branch March 9, 2023 09:02
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 Spanner API. kokoro:force-run Add this label to force Kokoro to re-run the tests. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants