Commit 6040296
authored
persist/pubsub: fix connection leak on gRPC stream error (#35938)
When the client's gRPC response stream errors, the reconnect loop drops
the tonic `Channel` but hyper's background task keeps running: It's
blocked polling the `broadcast_messages` async stream, which holds a
live `BroadcastStream` receiver. This keeps the HTTP2 connection open,
leaking one connection per reconnect.
Fix this by giving the stream a cancellation token. When the reconnect
loop drops `cancel_tx`, the stream observes it via `select!` and
terminates, allowing hyper to close the HTTP2 connection.
### Motivation
Fixes https://github.com/MaterializeInc/database-issues/issues/112761 parent 51c628a commit 6040296
1 file changed
Lines changed: 29 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
356 | 363 | | |
357 | 364 | | |
358 | 365 | | |
359 | 366 | | |
| 367 | + | |
360 | 368 | | |
361 | 369 | | |
362 | 370 | | |
| |||
370 | 378 | | |
371 | 379 | | |
372 | 380 | | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
380 | 400 | | |
381 | 401 | | |
382 | 402 | | |
383 | | - | |
384 | | - | |
385 | 403 | | |
386 | 404 | | |
387 | 405 | | |
| |||
403 | 421 | | |
404 | 422 | | |
405 | 423 | | |
| 424 | + | |
| 425 | + | |
406 | 426 | | |
407 | 427 | | |
408 | 428 | | |
| |||
0 commit comments