Skip to content

Conversation

@olavloite
Copy link
Collaborator

Adds an option to track the statement that starts a read/write transaction by inlining a BeginTransaction option with the request. This can be used to track down statements that do not return a transaction id in a timely fashon.

@olavloite olavloite requested a review from a team as a code owner December 23, 2020 08:27
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Dec 23, 2020
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/java-spanner API. label Dec 23, 2020
@codecov
Copy link

codecov bot commented Dec 23, 2020

Codecov Report

Merging #763 (f2b3a60) into master (c8ef46f) will increase coverage by 0.00%.
The diff coverage is 92.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #763   +/-   ##
=========================================
  Coverage     84.99%   85.00%           
+ Complexity     2562     2561    -1     
=========================================
  Files           143      143           
  Lines         13983    14007   +24     
  Branches       1335     1338    +3     
=========================================
+ Hits          11885    11906   +21     
- Misses         1537     1538    +1     
- Partials        561      563    +2     
Impacted Files Coverage Δ Complexity Δ
...gle/cloud/spanner/testing/RemoteSpannerHelper.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...om/google/cloud/spanner/TransactionRunnerImpl.java 84.70% <94.11%> (+0.33%) 9.00 <0.00> (ø)
...ain/java/com/google/cloud/spanner/SessionImpl.java 85.88% <100.00%> (+0.08%) 30.00 <0.00> (ø)
.../java/com/google/cloud/spanner/SpannerOptions.java 89.54% <100.00%> (+0.20%) 40.00 <1.00> (+1.00)
...a/com/google/cloud/spanner/SpannerRetryHelper.java 77.27% <0.00%> (-4.55%) 3.00% <0.00%> (-1.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c8ef46f...f2b3a60. Read the comment docs.

if (transactionIdFuture == null) {
transactionIdFuture = SettableApiFuture.create();
if (trackTransactionStarter) {
transactionStarter = new Exception("Requesting new transaction");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will create an Exception with the call stack of the statement that should return a transaction id. We keep track of this to be able to include it in any exception that could be thrown by later statements that timeout while waiting for this transaction id.

TransactionSelector.newBuilder().setId(tx.get()).build();
if (trackTransactionStarter) {
TransactionSelector.newBuilder()
.setId(tx.get(waitForTransactionTimeoutMillis, TimeUnit.MILLISECONDS))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Use a timeout if we are tracking the statement that should return a transaction id.

+ "See the suppressed exception for the stacktrace of the caller that should return a transaction",
e);
if (transactionStarter != null) {
se.addSuppressed(transactionStarter);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Include the stacktrace of the statement that should have returned the transaction in the exception that we are throwing.

@thiagotnunes thiagotnunes merged commit 3d9689c into master Dec 30, 2020
@thiagotnunes thiagotnunes deleted the track-transaction-starter branch December 30, 2020 02:11
ansh0l pushed a commit to ansh0l/java-spanner that referenced this pull request Nov 10, 2022
This is an auto-generated regeneration of the .pb.go files by
cloud.google.com/go/internal/gapicgen. Once this PR is submitted, genbot will
update the corresponding PR to depend on the newer version of go-genproto, and
assign reviewers. Whilst this or any regen PR is open in go-genproto, genbot
will not create any more regeneration PRs. If all regen PRs are closed,
gapicgen will create a new set of regeneration PRs once per night.

If you have been assigned to review this PR, please:

- Ensure that CI is passing. If it's failing, it requires your manual attention.
- Approve and submit this PR if you believe it's ready to ship. That will prompt
genbot to assign reviewers to the google-cloud-go PR.

Corresponding google-cloud-go PR: googleapis/google-cloud-go#5671

Changes:

fix(ruby): Update the google-cloud-dataplex-v1 dependency to version 0.2
  PiperOrigin-RevId: 429404615
  Source-Link: googleapis/googleapis@ab177dc

docs(samples): include metadata file, add exclusions for samples to handwritten libraries
  PiperOrigin-RevId: 429395631
  Source-Link: googleapis/googleapis@84594b3

build(pubsub): add flag to distinguish autogenerated libs with a handwritten layer
  PiperOrigin-RevId: 429391240
  Source-Link: googleapis/googleapis@f1529c0

build: add flag to distinguish autogenerated libs with a handwritten layer
  PiperOrigin-RevId: 429391190
  Source-Link: googleapis/googleapis@fb5fba4

fix(bigquery/storage)!: remove bigquery.readonly auth scope
  PiperOrigin-RevId: 429331987
  Source-Link: googleapis/googleapis@4b2bd26

chore: regenerate API index

  Source-Link: googleapis/googleapis@e8fdeb9

feat(logging): Update Logging API with latest changes
  PiperOrigin-RevId: 429289471
  Source-Link: googleapis/googleapis@acd5f89

docs: fix docstring formatting
  Committer: parthea
  PiperOrigin-RevId: 429178314
  Source-Link: googleapis/googleapis@f30b83d
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 googleapis/java-spanner API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants