Commit 53ebe2d
authored
xds: Fix half-close race condition in ext-proc client interceptor (#12888)
Resolve a protocol violation bug in ExternalProcessorClientInterceptor
and fix a related data race in its fail-open unit tests:
1. Interceptor Bug Fix (Incorrect Frame Order):
When the external processor stream fails (extProcStreamState is
FAILED/completed)
but the interceptor has not yet transitioned to pass-through mode, a
call to
sendMessage() is buffered, but a call to halfClose() immediately
executed
super.halfClose() because it only checked stream completion. This sent
the
halfClose frame to the backend server before the buffered message was
drained,
violating the gRPC protocol and causing the backend to drop the message.
Fixed by modifying halfClose() to only execute immediately if
passThroughMode
is true. If passThroughMode is false and the stream is completed/failed,
halfClose is buffered (pendingHalfClose = true) and deferred until the
draining
task drains the buffered messages and triggers it.
2. Test Fix (Deterministic Race Simulation):
Redesigned
givenFailureModeAllowTrue_whenExtProcStreamFails_thenCallFailsOpen
in ExternalProcessorClientInterceptorTest to deterministically simulate
the
interleaving that caused the bug. Used a custom ServerInterceptor on the
backend server to suspend the async onError thread inside activateLine()
(midway through fail-open processing) while the client main thread calls
sendMessage() and halfClose(). This forces the race condition and
verifies
that the message is no longer dropped.1 parent 0cf5239 commit 53ebe2d
2 files changed
Lines changed: 48 additions & 13 deletions
File tree
- xds/src
- main/java/io/grpc/xds
- test/java/io/grpc/xds
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
841 | 841 | | |
842 | 842 | | |
843 | 843 | | |
844 | | - | |
| 844 | + | |
845 | 845 | | |
846 | 846 | | |
847 | 847 | | |
| |||
850 | 850 | | |
851 | 851 | | |
852 | 852 | | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
853 | 857 | | |
854 | 858 | | |
855 | 859 | | |
| |||
867 | 871 | | |
868 | 872 | | |
869 | 873 | | |
870 | | - | |
871 | | - | |
872 | 874 | | |
873 | 875 | | |
874 | 876 | | |
| |||
Lines changed: 43 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8460 | 8460 | | |
8461 | 8461 | | |
8462 | 8462 | | |
8463 | | - | |
8464 | | - | |
8465 | | - | |
8466 | | - | |
8467 | | - | |
8468 | | - | |
8469 | | - | |
8470 | | - | |
| 8463 | + | |
| 8464 | + | |
| 8465 | + | |
| 8466 | + | |
| 8467 | + | |
| 8468 | + | |
| 8469 | + | |
| 8470 | + | |
| 8471 | + | |
| 8472 | + | |
| 8473 | + | |
| 8474 | + | |
| 8475 | + | |
| 8476 | + | |
| 8477 | + | |
| 8478 | + | |
| 8479 | + | |
| 8480 | + | |
| 8481 | + | |
| 8482 | + | |
| 8483 | + | |
| 8484 | + | |
| 8485 | + | |
| 8486 | + | |
| 8487 | + | |
| 8488 | + | |
| 8489 | + | |
8471 | 8490 | | |
8472 | 8491 | | |
8473 | 8492 | | |
8474 | 8493 | | |
| 8494 | + | |
8475 | 8495 | | |
8476 | 8496 | | |
8477 | 8497 | | |
8478 | 8498 | | |
| 8499 | + | |
8479 | 8500 | | |
8480 | 8501 | | |
8481 | 8502 | | |
| |||
8485 | 8506 | | |
8486 | 8507 | | |
8487 | 8508 | | |
8488 | | - | |
| 8509 | + | |
8489 | 8510 | | |
| 8511 | + | |
| 8512 | + | |
| 8513 | + | |
| 8514 | + | |
| 8515 | + | |
| 8516 | + | |
8490 | 8517 | | |
8491 | 8518 | | |
8492 | 8519 | | |
| 8520 | + | |
| 8521 | + | |
| 8522 | + | |
8493 | 8523 | | |
8494 | 8524 | | |
| 8525 | + | |
| 8526 | + | |
| 8527 | + | |
| 8528 | + | |
8495 | 8529 | | |
8496 | | - | |
8497 | 8530 | | |
8498 | 8531 | | |
8499 | 8532 | | |
| |||
0 commit comments