Skip to content

feat(spanner): add cache updates API#8307

Open
pearigee wants to merge 1 commit into
mainfrom
pearigee-fix-spanner
Open

feat(spanner): add cache updates API#8307
pearigee wants to merge 1 commit into
mainfrom
pearigee-fix-spanner

Conversation

@pearigee
Copy link
Copy Markdown
Contributor

PiperOrigin-RevId: 910759970

Source-Link: googleapis/googleapis@68f8f68

Source-Link: https://github.com/googleapis/googleapis-gen/commit/e68bcb7a76ca0a61bb702b2b8b5b08b5cddc10e5
Copy-Tag: eyJwIjoiaGFuZHdyaXR0ZW4vc3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiZTY4YmNiN2E3NmNhMGE2MWJiNzAyYjJiOGI1YjA4YjVjZGRjMTBlNSJ9

feat(spanner): isolation_level and read_lock_mode are added to message .google.spanner.v1.CommitResponse

PiperOrigin-RevId: 906456285

Source-Link: googleapis/googleapis@a7f4ee2

Source-Link: https://github.com/googleapis/googleapis-gen/commit/70ae95e2024111037f6f2883dc1c537486b26297
Copy-Tag: eyJwIjoiaGFuZHdyaXR0ZW4vc3Bhbm5lci8uT3dsQm90LnlhbWwiLCJoIjoiNzBhZTk1ZTIwMjQxMTEwMzdmNmYyODgzZGMxYzUzNzQ4NmIyNjI5NyJ9

@pearigee pearigee requested a review from a team as a code owner May 18, 2026 23:18
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label May 18, 2026
Copy link
Copy Markdown
Contributor

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

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 a new FetchCacheUpdate RPC to the Spanner service, along with associated request and response fields across several proto files to support location-aware requests and cache updates. Corresponding client library changes include the implementation of the fetchCacheUpdate streaming method and updated configuration. Feedback focuses on improving the proto definition by using the optional keyword for integer fields to track presence, ensuring proper error handling in the streaming client method to avoid unhandled promise rejections, and marking the new RPC as idempotent in the client configuration to enable automatic retries.

Comment on lines +1467 to +1471
int32 max_recipe_count = 2 [(google.api.field_behavior) = OPTIONAL];

// Optional. The maximum number of ranges to return in the response.
// If not set, a default limit of 10000 will be used.
int32 max_range_count = 3 [(google.api.field_behavior) = OPTIONAL];
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.

medium

The fields max_recipe_count and max_range_count are described as optional with default values if "not set". In proto3, standard int32 fields do not have presence tracking, meaning the server cannot distinguish between a value of 0 and the field being "not set". Using the optional keyword would allow the server to distinguish these states and provide a better developer experience if 0 is intended to be a valid (but non-default) limit.

Suggested change
int32 max_recipe_count = 2 [(google.api.field_behavior) = OPTIONAL];
// Optional. The maximum number of ranges to return in the response.
// If not set, a default limit of 10000 will be used.
int32 max_range_count = 3 [(google.api.field_behavior) = OPTIONAL];
optional int32 max_recipe_count = 2 [(google.api.field_behavior) = OPTIONAL];
// Optional. The maximum number of ranges to return in the response.
// If not set, a default limit of 10000 will be used.
optional int32 max_range_count = 3 [(google.api.field_behavior) = OPTIONAL];

Comment on lines +2729 to +2731
this.initialize().catch((err) => {
throw err;
});
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.

medium

The initialize().catch() block re-throws the error asynchronously. Since fetchCacheUpdate is not an async function and does not await this promise, the throw occurs in the microtask queue with no caller to catch it, leading to an unhandledRejection which can crash the Node.js process. For a streaming method, initialization errors should be emitted via the returned stream's 'error' event to ensure the client can handle them gracefully.

References
  1. For the Spanner library, use of APIs available in Node.js v18+ is permitted as older versions are not supported.

"retry_params_name": "default"
},
"FetchCacheUpdate": {
"retry_codes_name": "non_idempotent",
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.

medium

FetchCacheUpdate is marked as non_idempotent. Since this RPC is used for warming up the client cache and appears to be a read-only operation, it should likely be marked as idempotent to allow the client library to automatically retry on transient errors like UNAVAILABLE. This is especially important since gaxServerStreamingRetries is enabled for this method in the client constructor.

Suggested change
"retry_codes_name": "non_idempotent",
"retry_codes_name": "idempotent",

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 Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant