Repository navigation
Commit b731158
authored
core: prevent RetriableStream registry leak on cancel race (grpc#13083)
When `ClientCall.cancel()` races `ClientCall.start()` on a retry-enabled
channel, `RetriableStream.cancel()` can commit the stream before
`start()` calls `prestart()`.
The commit callback then removes nothing because the stream has not been
registered yet. `prestart()` subsequently registers the
already-committed stream, and the one-shot commit prevents any later
removal. This permanently retains the stream in
`UncommittedRetriableStreamsRegistry` and can delay channel shutdown.
This change makes `RetriableStream.start()` check whether the stream was
committed after `prestart()`. If so, it runs `postCommit()` again after
registration, allowing the registry to remove the stream.
Added regression coverage for retry streams, hedging streams, and
streams without retry or hedging policy.
Related issue: grpc#13034
Testing:
- `git diff --check` passed.
- The targeted local Gradle test could not resolve Gradle Plugin Portal
dependencies because DNS resolution failed in the Docker environment.
- The GitHub Actions JDK 17 job failed in the unrelated
`grpc-servlet-jakarta` test
`JettyTransportTest.frameAfterRstStreamShouldNotBreakClientChannel`; the
other reported checks passed.1 parent a74c398 commit b731158
2 files changed
Lines changed: 52 additions & 1 deletion
File tree
- core/src
- main/java/io/grpc/internal
- test/java/io/grpc/internal
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
402 | 406 | | |
403 | | - | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
404 | 415 | | |
405 | 416 | | |
406 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
238 | 278 | | |
239 | 279 | | |
240 | 280 | | |
| |||
0 commit comments