-
Notifications
You must be signed in to change notification settings - Fork 136
feat: Leader Aware Routing #2214
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
Changes from 1 commit
2cd2fbd
b57466a
32da417
cde93a3
606bbda
0156457
1bbd24d
f9152cd
90d455c
b1d44ce
c5d34ab
9c212af
426265d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
x-goog-spanner-route-to-leader header to Spanner RPC cont…
…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.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -267,7 +267,7 @@ public AsyncTransactionManagerImpl transactionManagerAsync(TransactionOption... | |
| @Override | ||
| public void prepareReadWriteTransaction() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I'll take a look. @yifanzyifanz: Please keep this comment unresolved for the time being. |
||
| setActive(null); | ||
| readyTransactionId = beginTransaction(); | ||
| readyTransactionId = beginTransaction(true); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -288,17 +288,17 @@ public void close() { | |
| } | ||
| } | ||
|
|
||
| ByteString beginTransaction() { | ||
| ByteString beginTransaction(boolean routeToLeader) { | ||
| try { | ||
| return beginTransactionAsync().get(); | ||
| return beginTransactionAsync(routeToLeader).get(); | ||
| } catch (ExecutionException e) { | ||
| throw SpannerExceptionFactory.newSpannerException(e.getCause() == null ? e : e.getCause()); | ||
| } catch (InterruptedException e) { | ||
| throw SpannerExceptionFactory.propagateInterrupt(e); | ||
| } | ||
| } | ||
|
|
||
| ApiFuture<ByteString> beginTransactionAsync() { | ||
| ApiFuture<ByteString> beginTransactionAsync(boolean routeToLeader) { | ||
| final SettableApiFuture<ByteString> res = SettableApiFuture.create(); | ||
| final Span span = tracer.spanBuilder(SpannerImpl.BEGIN_TRANSACTION).startSpan(); | ||
| final BeginTransactionRequest request = | ||
|
|
@@ -309,7 +309,7 @@ ApiFuture<ByteString> beginTransactionAsync() { | |
| .setReadWrite(TransactionOptions.ReadWrite.getDefaultInstance())) | ||
| .build(); | ||
| final ApiFuture<Transaction> requestFuture = | ||
| spanner.getRpc().beginTransactionAsync(request, options); | ||
| spanner.getRpc().beginTransactionAsync(request, options, routeToLeader); | ||
| requestFuture.addListener( | ||
| tracer.withSpan( | ||
| span, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.