Skip to content

xds: fix race condition in ext_proc client interceptor halfClose - #12948

Merged
kannanjgithub merged 1 commit into
grpc:masterfrom
kannanjgithub:halfClose-draining-race-fix
Aug 5, 2026
Merged

xds: fix race condition in ext_proc client interceptor halfClose#12948
kannanjgithub merged 1 commit into
grpc:masterfrom
kannanjgithub:halfClose-draining-race-fix

Conversation

@kannanjgithub

@kannanjgithub kannanjgithub commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Fixes a race condition in ExternalProcessorClientInterceptor$DataPlaneClientCall.halfClose() that can cause the call to hang when the external processor stream completes concurrently.

If the external processor stream completes (marking state as COMPLETED and setting passThroughMode to true) after halfClose() has already checked passThroughMode (seeing false), halfClose() would subsequently see the state as COMPLETED and return early without invoking proceedWithHalfClose().

This commit fixes the race by re-checking passThroughMode inside the isCompleted() block in halfClose(), ensuring we proceed with half-close if pass-through mode was enabled late.

Fixes a race condition in ExternalProcessorClientInterceptor$DataPlaneClientCall.halfClose()
that can cause the call to hang when the external processor stream completes concurrently.

If the external processor stream completes (marking state as COMPLETED and setting
passThroughMode to true) after halfClose() has already checked passThroughMode (seeing false),
halfClose() would subsequently see the state as COMPLETED and return early without
invoking proceedWithHalfClose().

This commit fixes the race by re-checking passThroughMode inside the isCompleted() block in
halfClose(), ensuring we proceed with half-close if pass-through mode was enabled late.
@kannanjgithub
kannanjgithub requested a review from sauravzg July 29, 2026 13:52

@sauravzg sauravzg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a test for this case if possible to reproduce.

@kannanjgithub

Copy link
Copy Markdown
Contributor Author

We should add a test for this case if possible to reproduce.

It is not, the window for race is tiny and it entirely depends on processor scheduling and preemptions, so it cannot reproduced at will via a test.

@kannanjgithub
kannanjgithub merged commit adf01bf into grpc:master Aug 5, 2026
15 of 18 checks passed
@kannanjgithub
kannanjgithub deleted the halfClose-draining-race-fix branch August 5, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants