-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
…ts for RW/PDML transactions.
spanner/transaction.go
Outdated
@@ -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{ |
There was a problem hiding this comment.
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?
spanner/client.go
Outdated
// need to be routed to the leader region. | ||
// | ||
// Default: true | ||
RouteToLeader bool |
There was a problem hiding this comment.
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.
spanner/transaction.go
Outdated
@@ -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{ |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed
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.