GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(x-goog-spanner-request-id): implement Request-ID by odeke-em · Pull Request #1264 · googleapis/python-spanner

This repository was archived by the owner on Jun 8, 2026. It is now read-only.

Conversation

@odeke-em

@odeke-em odeke-em commented Dec 11, 2024

Copy link
Copy Markdown
Contributor

Implements x-goog-spanner-request-id propagation for end-to-end debugging.

Fixes googleapis/google-cloud-python#15905

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@product-auto-label product-auto-label Bot added the size: m Pull request size is medium. label Dec 11, 2024
@conventional-commit-lint-gcf

conventional-commit-lint-gcf Bot commented Dec 11, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🤖 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 automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@product-auto-label product-auto-label Bot added the api: spanner Issues related to the googleapis/python-spanner API. label Dec 11, 2024
@odeke-em
odeke-em force-pushed the x-goog-spanner-request-id branch from 2451afe to 4f1da67 Compare December 12, 2024 08:13
@odeke-em odeke-em changed the title feat(x-goog-spanner-request-id): implement Requst-ID feat(x-goog-spanner-request-id): implement Request-ID Dec 12, 2024
@odeke-em
odeke-em force-pushed the x-goog-spanner-request-id branch from b021c9e to 47da5e4 Compare December 14, 2024 13:13
@product-auto-label product-auto-label Bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Dec 14, 2024
@odeke-em
odeke-em force-pushed the x-goog-spanner-request-id branch from 8616572 to caa60c2 Compare December 16, 2024 12:23
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Dec 18, 2024
@odeke-em
feat(x-goog-spanner-request-id): introduce AtomicCounter
1f52008
This change introduces AtomicCounter, a concurrency/thread-safe
counter do deal with the multi-threaded nature of variables.
It permits operations:
* atomic_counter += 1
* value = atomic_counter + 1
* atomic_counter.value

that'll be paramount to bringing in the logic for
x-goog-spanner-request-id in much reduced changelists.

Updates #1261
Carved out from PR googleapis#1264
@odeke-em odeke-em mentioned this pull request Dec 18, 2024
feat(x-goog-spanner-request-id): introduce AtomicCounter #1275
Merged
@odeke-em
odeke-em force-pushed the x-goog-spanner-request-id branch from 9903cac to 529333a Compare December 18, 2024 14:25
@odeke-em
odeke-em marked this pull request as ready for review December 18, 2024 14:26
@odeke-em
odeke-em requested review from a team December 18, 2024 14:26
@blunderbuss-gcf blunderbuss-gcf Bot assigned thiagotnunes Dec 18, 2024
@product-auto-label product-auto-label Bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Dec 19, 2024
@olavloite olavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 19, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 19, 2024
olavloite added a commit that referenced this pull request Dec 19, 2024
@odeke-em @olavloite
feat(x-goog-spanner-request-id): introduce AtomicCounter (#1275)
f2483e1
* feat(x-goog-spanner-request-id): introduce AtomicCounter

This change introduces AtomicCounter, a concurrency/thread-safe
counter do deal with the multi-threaded nature of variables.
It permits operations:
* atomic_counter += 1
* value = atomic_counter + 1
* atomic_counter.value

that'll be paramount to bringing in the logic for
x-goog-spanner-request-id in much reduced changelists.

Updates #1261
Carved out from PR #1264

* Tests for with_request_id

* chore: remove sleep

* chore: remove unused import

---------

Co-authored-by: Knut Olav Løite <[email protected]>
@odeke-em
odeke-em force-pushed the x-goog-spanner-request-id branch from 2d6a3ea to 65757b5 Compare December 20, 2024 05:37
olavloite
olavloite reviewed Dec 24, 2024
View reviewed changes
Comment thread google/cloud/spanner_v1/database.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/database.py Outdated
_metadata_with_leader_aware_routing(self._route_to_leader_enabled)
)

# Attempt will be incremented inside _restart_on_unavailable.

@olavloite olavloite Dec 19, 2024

Copy link
Copy Markdown
Contributor

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 assume that this comment applies to partial_attempt, no? If so, can we move it down to that variable.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@odeke-em odeke-em Dec 24, 2024

Copy link
Copy Markdown
Contributor Author

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.

It applies to begin_txn_attempt and I've updated the comment and moving the comment before the variable itself. Thank you.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/spanner_v1/database.py Outdated
request=request,
transaction_selector=txn_selector,
observability_options=self.observability_options,
attempt=begin_txn_attempt,

@olavloite olavloite Dec 24, 2024

Copy link
Copy Markdown
Contributor

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 this should be partial_attempt. Retries of this RPC will not retry the BeginTransaction RPC, it will just continue to use the same transaction ID as the one that was returned by the original BeginTransaction RPC.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@odeke-em odeke-em Dec 24, 2024

Copy link
Copy Markdown
Contributor Author

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.

Oooh, okay, that's very interesting and thanks for letting me know, let me make that update.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@odeke-em odeke-em Dec 24, 2024

Copy link
Copy Markdown
Contributor Author

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 did however already pass in and increment partial_attempt inside wrapped_method. I'll instead remove that and increment them in the appropriate sites.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/spanner_v1/instance.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/test_request_id_header.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/test_request_id_header.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/test_request_id_header.py
]
assert got_stream_segments == want_stream_segments

def test_database_run_in_transaction_retries_on_abort(self):

@olavloite olavloite Dec 24, 2024

Copy link
Copy Markdown
Contributor

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.

This test does not appear to actually verify anything (other than that it does not cause any errors). Can we either remove it, or add verifications for the scenario it should cover?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tests/unit/test_session.py Outdated
("x-goog-spanner-route-to-leader", "true"),
(
"x-goog-spanner-request-id",
f"1.{REQ_RAND_PROCESS_ID}.{database.NTH_CLIENT.value}.1.2.2",

@olavloite olavloite Dec 24, 2024

Copy link
Copy Markdown
Contributor

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.

Is attempt set to 2 here because the transaction is retried? If so, then that is not correct. The attempt number should only be increased if the RPC itself is being retried due to a retryable error for that (single) RPC. E.g. if a ServiceUnavailable error is returned.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tests/unit/test_session.py Outdated
("x-goog-spanner-route-to-leader", "true"),
(
"x-goog-spanner-request-id",
f"1.{REQ_RAND_PROCESS_ID}.{database.NTH_CLIENT.value}.1.3.2",

@olavloite olavloite Dec 24, 2024

Copy link
Copy Markdown
Contributor

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.

Same here as for the BeginTransaction RPC: Transaction retries should not increase the attempt count. Only retries of a single RPC due to UNAVAILABLE errors (and other retryable error codes).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@olavloite olavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 24, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 24, 2024
@odeke-em
odeke-em force-pushed the x-goog-spanner-request-id branch from f8e0717 to 7fc3f3f Compare December 24, 2024 21:54
@olavloite olavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 25, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 25, 2024
@odeke-em
odeke-em force-pushed the x-goog-spanner-request-id branch from 07a00f9 to 70eeaef Compare December 25, 2024 14:03
@olavloite olavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 26, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 25, 2025
@odeke-em
odeke-em force-pushed the x-goog-spanner-request-id branch from 4484cfd to 3bda544 Compare March 28, 2025 11:23
@odeke-em
odeke-em requested a review from olavloite March 28, 2025 11:24
@odeke-em
Initial ExecuteStreamingSql request in snapshot should have the header
f8ad94f
@odeke-em
odeke-em force-pushed the x-goog-spanner-request-id branch from 3bda544 to f8ad94f Compare March 28, 2025 11:27
@sakthivelmanii sakthivelmanii added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 28, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 28, 2025
odeke-em added 4 commits March 28, 2025 16:05
@odeke-em
Consolidate retries for _restart_on_unavailable
15984cb
@odeke-em
Fix missing variable declaration
a5fdebd
@odeke-em
Adjust with updates
80faca0
@odeke-em
Update _execute_partitioned_dml_helper
06c12a2
@sakthivelmanii sakthivelmanii added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 1, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 1, 2025
@odeke-em
Monkey patch updates
9d4d942
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Apr 30, 2025
@odeke-em
chore(x-goog-request-id): commit testing scaffold
eb2c3d2
This change commits the scaffolding for which testing
will be used. This is a carve out of PRs googleapis#1264 and googleapis#1364,
meant to make those changes lighter and much easier to
review then merge.

Updates #1261
@odeke-em odeke-em mentioned this pull request Apr 30, 2025
chore(x-goog-request-id): commit testing scaffold #1366
Merged
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Apr 30, 2025
@odeke-em
chore(x-goog-request-id): commit testing scaffold
129f662
This change commits the scaffolding for which testing
will be used. This is a carve out of PRs googleapis#1264 and googleapis#1364,
meant to make those changes lighter and much easier to
review then merge.

Updates #1261
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Apr 30, 2025
@odeke-em
chore(x-goog-request-id): commit testing scaffold
6f10a1f
This change commits the scaffolding for which testing
will be used. This is a carve out of PRs googleapis#1264 and googleapis#1364,
meant to make those changes lighter and much easier to
review then merge.

Updates #1261
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request May 2, 2025
@odeke-em
chore(x-goog-request-id): commit testing scaffold
7e24e61
This change commits the scaffolding for which testing
will be used. This is a carve out of PRs googleapis#1264 and googleapis#1364,
meant to make those changes lighter and much easier to
review then merge.

Updates #1261
olavloite pushed a commit that referenced this pull request May 7, 2025
@odeke-em
chore(x-goog-request-id): commit testing scaffold (#1366)
686bda6
* chore(x-goog-request-id): commit testing scaffold

This change commits the scaffolding for which testing
will be used. This is a carve out of PRs #1264 and #1364,
meant to make those changes lighter and much easier to
review then merge.

Updates #1261

* Use guard to keep x-goog-request-id interceptor docile in tests until activation later

* AtomicCounter update

* Remove duplicate unavailable_status that had been already committed into main
@odeke-em
Merge branch 'main' into x-goog-spanner-request-id
6ed0b74
@product-auto-label product-auto-label Bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels May 17, 2025
odeke-em added 3 commits May 17, 2025 13:32
@odeke-em
Reduce unnecessary changes
c31c03f
@odeke-em
Experiment with wrapping for gapic retries
e67cc9e
@odeke-em
Remove duplicate code
dab92dd
@odeke-em
odeke-em force-pushed the x-goog-spanner-request-id branch from 6fe1810 to dab92dd Compare May 19, 2025 01:40
@odeke-em
Complete mockserver tests
4334dd4
@odeke-em

odeke-em commented Jun 5, 2025

Copy link
Copy Markdown
Contributor Author

Superseeded by a whole lot of smaller PRs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@odeke-em odeke-em closed this Jun 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@olavloite olavloite Awaiting requested review from olavloite

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@thiagotnunes thiagotnunes

Labels

api: spanner Issues related to the googleapis/python-spanner API. size: l Pull request size is large.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Implement propagation of x-goog-spanner-request-id gRPC header on every call

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@odeke-em @olavloite @thiagotnunes @yoshi-kokoro @sakthivelmanii
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.