Skip to content

Conversation

@JoeCqupt
Copy link
Contributor

@JoeCqupt JoeCqupt commented Mar 3, 2025

fix #11853

Use ServerCallStreamObserver.setOnCancelHandler() to disable this exception

@JoeCqupt
Copy link
Contributor Author

JoeCqupt commented Mar 4, 2025

@zhangkun83 @carl-mastrangelo PTAL @kannanjgithub

@JoeCqupt JoeCqupt changed the title fix HealthService notifyWatchers services: fix HealthService notifyWatchers Mar 10, 2025
Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

I don't think we want to catch the exception. I think we want to avoid the exception by using setOnCancelHandler() as mentioned in the error to update watchers. That will release resources as soon as the RPC is cancelled.

@ejona86 ejona86 added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Mar 21, 2025
@grpc-kokoro grpc-kokoro removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Mar 21, 2025
@ejona86 ejona86 requested a review from kannanjgithub March 24, 2025 21:12
@kannanjgithub kannanjgithub merged commit 350f90e into grpc:master Mar 25, 2025
16 checks passed
@ejona86
Copy link
Member

ejona86 commented Mar 25, 2025

@JoeCqupt, thank you!

Sangamesh1997 pushed a commit to Sangamesh1997/grpc-java that referenced this pull request Apr 3, 2025
…already have their connections cancelled (grpc#11934)

Some clients watching health status can cancel their watch and `HealthService` when trying to notify these watchers were getting CANCELLED exception because there was no cancellation  handler set on the `StreamObserver`. This change sets the cancellation handler that removes the watcher from the set of watcher clients to be notified of the health status.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HealthStatusManager.setStatus can throw a runtime exception when notifying (already cancelled) watchers

4 participants