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
| } | ||
| } | ||
| 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.
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.
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
| } | ||
| } | ||
| 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.
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?
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.