Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ads): check if channel is closed #13

Open
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

lukidzi
Copy link

@lukidzi lukidzi commented Feb 7, 2025

We have observed that sometimes writing to the channel happens when the channel is already closed. This issue is related to #1023.

Upon reviewing the code, I found that the value channel can be created by one goroutine, while a different goroutine handles sending data on this channel. The first goroutine depends on the existence of the stream and requests, while the second one is triggered from SetSnapshot, which operates with a different context than the server.

There appears to be a race condition where the stream is canceled, and resources start to be cleaned up, while the context in SetSnapshot might cancel later, leading to writing on a closed channel.

This is not a complete fix but should prevent the panic. We should aim to fix this by possibly keeping the context within the watch and checking for its cancellation, or other?

@lukidzi lukidzi requested review from a team, slonka and Automaat and removed request for a team February 7, 2025 18:31
@lukidzi lukidzi changed the title fix(ads): check if channel is open fix(ads): check if channel is closed Feb 7, 2025
@lukidzi lukidzi force-pushed the write-closed-channel branch from 72164f4 to 36b8f96 Compare February 7, 2025 18:32
Signed-off-by: Lukasz Dziedziak <[email protected]>
@lukidzi lukidzi force-pushed the write-closed-channel branch from 36b8f96 to 8487b18 Compare February 7, 2025 18:48
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