feat: Leader Aware Routing#2214
Conversation
|
🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use -- conventional-commit-lint bot |
x-goog-spanner-route-to-leader header to Spanner RPC contexts f…x-goog-spanner-route-to-leader header to Spanner RPC contexts f…
…exts for RW/PDML transactions. 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.
…re routing feature
olavloite
left a comment
There was a problem hiding this comment.
LGTM, with a couple of nits.
Tip: You could add an extra verification to this test to verify that the header is really sent to Cloud Spanner:
| @@ -275,7 +275,7 @@ public AsyncTransactionManagerImpl transactionManagerAsync(TransactionOption... | |||
| @Override | |||
| public void prepareReadWriteTransaction() { | |||
There was a problem hiding this comment.
Not relevant for this PR, but note to self/other readers: This seems like a method that can be cleaned up. I don't think it is in use anymore. @rajatbhatta Would you mind taking a look at that?
There was a problem hiding this comment.
Sure, I'll take a look. @yifanzyifanz: Please keep this comment unresolved for the time being.
There was a problem hiding this comment.
LGTM (apart from one of my pending comments and nits from @olavloite)
| @@ -275,7 +275,7 @@ public AsyncTransactionManagerImpl transactionManagerAsync(TransactionOption... | |||
| @Override | |||
| public void prepareReadWriteTransaction() { | |||
There was a problem hiding this comment.
Sure, I'll take a look. @yifanzyifanz: Please keep this comment unresolved for the time being.
…eader header exists for RW transactions and does not exist for RO transactions or when the leader aware routing feature is disabled.
rajatbhatta
left a comment
There was a problem hiding this comment.
Adding "Request changes" to prevent accidental merge of this PR. Note that the changes still look good to me.
x-goog-spanner-route-to-leader header to Spanner RPC contexts f…|
Changing the Title to make it consistent across clients. |
Add
x-goog-spanner-route-to-leaderheader to Spanner RPC contexts for RW/PDML transactions.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.
This feature is off by default and can be enabled by enabling Leader Aware Routing while creating Spanner object.
Spanner spanner = SpannerOptions.newBuilder().enableLeaderAwareRouting().build().getService();