Skip to content

Allow async events processing without holding total_consistency_lock#2199

Merged
TheBlueMatt merged 4 commits intolightningdevkit:mainfrom
tnull:2023-04-fix-async-event-processing
Apr 22, 2023
Merged

Allow async events processing without holding total_consistency_lock#2199
TheBlueMatt merged 4 commits intolightningdevkit:mainfrom
tnull:2023-04-fix-async-event-processing

Conversation

@tnull
Copy link
Copy Markdown
Contributor

@tnull tnull commented Apr 18, 2023

Fixes #2003.

Unfortunately, the RAII types used by RwLock are not Send, which is why they can't be held over await boundaries. In order to allow asynchronous events processing in multi-threaded environments, we here allow to process events without holding the total_consistency_lock. We do so by cloning the events and only draining and persisting the queue after they have successfully been processed.

The first commit reverts a prior commit of #2177, as we now want the behavior of the two process_event methods to diverge, i.e., want to avoid cloning in the sync case.

I tried to be minimally invasive as the event processing will receive a general overhaul with #2167 and follow-ups and any more substantial changes would likely only make sense after they have landed.

Loading
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.

Switch total_consistency_lock to a Send RwLock variant

6 participants