feat(spanner): add cache updates API#8307
Conversation
There was a problem hiding this comment.
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.
| 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]; |
There was a problem hiding this comment.
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.
| 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]; |
| this.initialize().catch((err) => { | ||
| throw err; | ||
| }); |
There was a problem hiding this comment.
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
- 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", |
There was a problem hiding this comment.
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.
| "retry_codes_name": "non_idempotent", | |
| "retry_codes_name": "idempotent", |
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