fix(example): potentional race-condition in consumer-group example - #3674
fix(example): potentional race-condition in consumer-group example#3674mabrarov wants to merge 1 commit into
Conversation
puellanivis
left a comment
There was a problem hiding this comment.
As noted, no, there was not a potential race condition in the previous example. No, not even a potential for one.
If we’re going to fix this code, then we should do a full rewrite with signal.NotifyContext setup from the start, and we don’t need a whole complicated sync.OnceXY pattern because there’s only one place that might ever close the channel, and it’s only ever possible that a single thread could ever be in that code already… but like I explained, we don’t need that ready condition anyways.
We can just go straight away to the wait for NotifyContext to close. There’s no reason to have to wait for the consumer to be ready. Entirely removing all of this code means everything still works.
|
Hi @puellanivis, I am under impression that waiting for ready condition in this example is used to demonstrate what Regarding lack of race-condition - I replied in #1404 (comment) - it's more about correctness than about reproducible bug (which is usual for the issues of race-condition nature). Thank you. |
This is still not a proper reason for why it waits to setup the signal handler. It’s absurd that we will simply crash out on a |
|
Considering #1404 (comment) - if we still want to keep waiting for |
Probably. 🤷♀️ We should still clean up everything else. Move the signal handler to start, and then There’s nothing wrong with the code as is, but it’s insufficient for the scope of changes that are being made. |
Fix race-condition in consumer-group example when waiting for consumer readiness. Refer to #1404 (comment).