Skip to content

feat(datastore): add x-goog-is-transaction routing header - #14767

Open
nikhilchowdary wants to merge 1 commit into
googleapis:mainfrom
nikhilchowdary:feat/datastore-is-transaction-header
Open

nikhilchowdary wants to merge 1 commit into
googleapis:mainfrom
nikhilchowdary:feat/datastore-is-transaction-header

Conversation

@nikhilchowdary

Copy link
Copy Markdown

Add x-goog-is-transaction routing header in java SDK to differentiate transactional requests and non-transactional requests from each other. Having a routing header for transactions helps in routing grpc requests at GFE.

This commit attaches the x-goog-is-transaction routing header to all RPCs

  • Set to true for transactional RPCs
    -- beginTransaction
    -- rollback
    -- transactional commit
    -- transactional lookup
    -- transactional runQuery
    -- transactional runAggregationQuery.

  • Set to false for non transactional RPCs
    -- allocateIds
    -- non transactional commit
    -- non transactional lookup
    -- non transactional runQuery
    -- non transactional runAggregationQuery.

cc: @MarkDuckworth

@nikhilchowdary
nikhilchowdary requested a review from a team as a code owner October 25, 2026 07:05

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the 'x-goog-is-transaction' header to both gRPC and HTTP Datastore RPC implementations to indicate whether an RPC is part of a transaction. In GrpcDatastoreRpc, this is handled by passing specific ApiCallContext instances, while HttpDatastoreRpc utilizes a ThreadLocal to track and set the header dynamically. Comprehensive unit tests are also introduced to verify this header routing logic. The review feedback recommends extracting a private helper method isTransactionalRead in HttpDatastoreRpc to eliminate duplicate logic when checking if a read operation is transactional across the lookup, runQuery, and runAggregationQuery methods.

@nikhilchowdary
nikhilchowdary force-pushed the feat/datastore-is-transaction-header branch from 5a1dff1 to cf7244a Compare October 25, 2026 07:14
This commit attaches the `x-goog-is-transaction` routing header to all gRPC calls in the Cloud Datastore Java SDK (`GrpcDatastoreRpc`):
- Set to `true` for transactional RPCs (`beginTransaction`, `rollback`, and transactional `commit`, `lookup`, `runQuery`, `runAggregationQuery`).
- Set to `false` for non-transactional RPCs (`allocateIds`, `reserveIds`, and non-transactional `commit`, `lookup`, `runQuery`, `runAggregationQuery`).
@nikhilchowdary
nikhilchowdary force-pushed the feat/datastore-is-transaction-header branch from cf7244a to a43c49e Compare October 26, 2026 07:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant