stacks-core icon indicating copy to clipboard operation
stacks-core copied to clipboard

Synchronization in event emitter between different events

Open kantai opened this issue 4 years ago • 3 comments

Currently, the event emitter does not synchronize across threads, and some events are processed in different threads. This can lead to situations like the following:

Block A -> microblock 1

That is, microblock 1 depends on Block A. The node processes Block A and emits a new_block event for A, but before it does so, the thread that processes microblock events emits a new_microblock event for microblock 1. This race condition is possible because they process in two different threads.

Event observers could potentially handle this race condition by queueing microblock events, but the event emitter could also handle this condition by synchronizing across threads. Of course, this could be both dangerous (due to the new possibilities of deadlock) and performance degrading (due to serialization). However, I think the topic is worth discussing, so I'm opening this issue!

kantai avatar Sep 17 '21 16:09 kantai

Related to #2183

jcnelson avatar Sep 20 '21 15:09 jcnelson

Small correction, related to https://github.com/blockstack/stacks-blockchain/issues/2813, not 2183. :)

CharlieC3 avatar Sep 20 '21 15:09 CharlieC3

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 21 '22 02:09 stale[bot]

This issue has been automatically closed. Please reopen if needed.

stale[bot] avatar Oct 22 '22 20:10 stale[bot]

Not stale

zone117x avatar Nov 15 '22 12:11 zone117x

Temporarily assigning to @kantai so this has an owner. Please feel free to re-assign.

jcnelson avatar Feb 22 '23 03:02 jcnelson