question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Races involving channels can result in dropped messages

See original GitHub issue

I’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:

monitor

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:closed
  • Created 7 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, Oct 20, 2016

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.

0reactions
Andaristcommented, Oct 30, 2016

It took some time, but the fix finally has landed in the newest version! v0.12.1 has been published.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found