fix(datastore): add retries to emulator#14591
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the Datastore client's retry policy and emulator connection logic. The retryPolicy now includes waitForReady: true and provides a default configuration for all service methods. The NewClientWithDatabase function was updated to better handle various gRPC target schemes for the emulator host and to apply consistent keepalive and retry configurations across both standard and emulator clients. I have no feedback to provide as there were no review comments.
hongalex
approved these changes
May 15, 2026
This was referenced May 15, 2026
bhshkh
added a commit
that referenced
this pull request
May 19, 2026
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v0.13.2-0.20260518181009-04b8e642ea4c Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-go@sha256:b04b076f5eedbb5546bd6fc1404969dd3698c8b19c0f34ae815a84ae735a606a <details><summary>datastore: v1.24.0</summary> ## [v1.24.0](datastore/v1.23.0...datastore/v1.24.0) (2026-05-19) ### Bug Fixes * detach rollback context from transaction cancellation (#14602) ([0a8d10d](0a8d10d1)) * fix context leak in Iterator and Transaction spans (#14478) ([78de20d](78de20da)) * add retries to emulator (#14591) ([d944830](d9448309)) </details>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR refines the Datastore client's resilience logic to fix regressions identified during TAP testing, specifically regarding emulator startup races, Unix domain sockets, and IPv6 literals. It ensures that the resilience benefits for bug b/473841984 are applied consistently to both production and emulator environments without breaking existing tests.
Why these changes are needed
exchange:datastore_test) experience a "connection refused" error if an RPC is attempted immediately after starting the emulator process. By adding"waitForReady": trueto the gRPC Service Config, the client will now block and wait for the emulator to finish binding its port instead of failing the RPC immediately.waitForReadyenabled, an unreachable host could cause a test to hang indefinitely. This PR adds a canonical"timeout": "60s"to the genericmethodConfigto ensure RPCs eventually fail with a clear error.tinoften use Unix domain sockets (unix:///) or IPv6 literals ([::1]) for emulator addresses. Previous logic would mangle these into invalid targets (e.g.,passthrough:///unix:///...), leading to "too many colons" errors or connection hangs. The updated logic defensively checks for existing valid schemes before applying thepassthrough:///optimization.Commit: A catch-all configuration block is added to the Service Config to ensure thatUNAVAILABLEerrors are retried for all methods, includingCommit(used byPutMulti), which was previously omitted.Why PR #14411 was insufficient
While PR #14411 introduced Keepalives and expanded retries for idempotent calls, it had several gaps:
waitForReady: trueto the Service Config, it removed the "wait" period needed for emulators to become ready.passthrough:///did not account forunix:///schemes or bracketed IPv6 literals, causing dialer errors in specialized test environments. (Even though the passthrough was not added in PR fix(datastore): enable gRPC keepalives and expand retries #14411, the current google3 imported code did not have this logic. While trying to import cl/906545069 latest code with psssthrough, this issue was discovered. )Related Bug
b/473841984