Commit d944830
authored
fix(datastore): add retries to emulator (#14591)
**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](http://b/473841984)** are applied consistently to both
production and emulator environments without breaking existing tests.
**Why these changes are needed**
1. **Handling Emulator Startup Races**: Many tests (e.g.,
`exchange:datastore_test`) experience a "connection refused" error if an
RPC is attempted immediately after starting the emulator process. By
adding **`"waitForReady": true`** to 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.
2. **Preventing Infinite Hangs**: With `waitForReady` enabled, an
unreachable host could cause a test to hang indefinitely. This PR adds a
canonical **`"timeout": "60s"`** to the generic `methodConfig` to ensure
RPCs eventually fail with a clear error.
3. **Robust Scheme Handling (Unix Sockets & IPv6)**: Internal test
environments like `tin` often 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 the
`passthrough:///` optimization.
4. **Idempotent Retries for `Commit`**: A catch-all configuration block
is added to the Service Config to ensure that **`UNAVAILABLE`** errors
are retried for all methods, including `Commit` (used by `PutMulti`),
which was previously omitted.
**Why PR #14411 was insufficient**
While PR #14411 introduced Keepalives and expanded retries for
idempotent calls, it had several gaps:
* It only applied the new configuration to the **production** code path,
leaving the emulator path without resilience logic or standardized
retries.
* By removing the manual 100ms retry loop without adding `waitForReady:
true` to the Service Config, it removed the "wait" period needed for
emulators to become ready.
* The aggressive prepending of `passthrough:///` did not account for
`unix:///` schemes or bracketed IPv6 literals, causing dialer errors in
specialized test environments. (Even though the passthrough was not
added in PR #14411, the current google3 imported code did not have this
logic. While trying to import [cl/906545069](http://cl/906545069) latest
code with psssthrough, this issue was discovered. )
**Related Bug**
[b/473841984](http://b/473841984)1 parent c5aaedc commit d944830
1 file changed
Lines changed: 47 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
63 | 79 | | |
64 | | - | |
| 80 | + | |
65 | 81 | | |
66 | 82 | | |
67 | 83 | | |
| |||
126 | 142 | | |
127 | 143 | | |
128 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
129 | 151 | | |
130 | 152 | | |
131 | 153 | | |
132 | 154 | | |
133 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
134 | 161 | | |
135 | | - | |
| 162 | + | |
136 | 163 | | |
137 | 164 | | |
| 165 | + | |
| 166 | + | |
138 | 167 | | |
139 | 168 | | |
140 | 169 | | |
| |||
153 | 182 | | |
154 | 183 | | |
155 | 184 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 185 | + | |
161 | 186 | | |
162 | 187 | | |
163 | 188 | | |
| |||
0 commit comments