Races involving channels can result in dropped messages
See original GitHub issueI’m using channels extensively for private communication between sagas. I have a watch
saga that races three channels: one for receiving requests, one for receiving responses, and one for handling details of the request itself.
It seems the race effect guarantees a single winner, even if more than one channel has a message. The messages from the losers are dropped.
Here’s a sagaMonitor screenshot which I hope demonstrates the problem:
In the code, I have:
const { request, handler, response } = yield race({
request: take(channelRequest),
handler: take(channelHandler),
response: take(channelResponse),
});
In the case shown in the screenshot, only handler
was set after that code. The other two variables were undefined
. Next time response
won the race, its message was NOT the one shown in the screenshot: it was a subsequent one.
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Race condition - Wikipedia
Race conditions can occur especially in logic circuits, multithreaded, or distributed software programs.
Read more >Data Race Patterns in Go | Uber Blog
Two or more goroutines can communicate data either via message passing (channels) or shared memory. Shared memory happens to be the most ...
Read more >Consumer Acknowledgements and Publisher Confirms
Acknowledging on a different channel will result in an "unknown delivery tag" ... instruct RabbitMQ to record a message as delivered and can...
Read more >Critical Issues Addressed in PAN-OS Releases
Bugs Affected Platform(if any). /Affected Version Description (release note)
PAN‑92564 8.0.0‑8.0‑8, 8.1.0
PAN‑86882 8.0.0‑8.0.7. and all older Mainlines
PAN‑81990 PA‑5220,PA‑5250. /. 8.0.4 Multiple DP restarts by...
Read more >Communication and Dissemination Strategies To Facilitate the ...
Targeting the message : Targeting (also referred to as audience segmentation) involves the development of an intervention approach for a defined population ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If I understand you correctly your code is fine, however for now you might lose some buffered items WHEN in the exact moment of
yield race
you have waiting items in both queues. In the same moment they wont be both returned to the saga, only the first one will be, and the second one will get dropped in the bakcground silently without you even knowing that.Fix is already on the master, I’ll try to have it published asap as
0.12.1
.It took some time, but the fix finally has landed in the newest version!
v0.12.1
has been published.