Skip to content

feat(consensus): add loopback queue for primary self-addressed messages#2825

Open
hubcio wants to merge 2 commits intomasterfrom
loopback-queue
Open

feat(consensus): add loopback queue for primary self-addressed messages#2825
hubcio wants to merge 2 commits intomasterfrom
loopback-queue

Conversation

@hubcio
Copy link
Contributor

@hubcio hubcio commented Feb 26, 2026

The primary was sending PrepareOk to itself through the message
bus, requiring a network round-trip and an unwrap() on bus
errors. Replace with an in-process VecDeque that the simulator
drains after each dispatch. Cleared on view change reset and
on DVC quorum completion.

Includes defensive debug_assert guards on push_loopback
overflow, process_loopback buf precondition, and simulator
drain idempotency. Adds test verifying loopback is cleared
when complete_view_change_as_primary fires.

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 76.82119% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.88%. Comparing base (2eefbc3) to head (fbda38a).

Files with missing lines Patch % Lines
core/shard/src/lib.rs 0.00% 30 Missing ⚠️
core/simulator/src/lib.rs 0.00% 4 Missing ⚠️
core/consensus/src/impls.rs 92.30% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2825      +/-   ##
============================================
+ Coverage     67.53%   67.88%   +0.35%     
  Complexity      739      739              
============================================
  Files          1048     1048              
  Lines         84103    84247     +144     
  Branches      60704    60857     +153     
============================================
+ Hits          56795    57195     +400     
+ Misses        24950    24678     -272     
- Partials       2358     2374      +16     
Flag Coverage Δ
csharp 67.06% <ø> (-0.19%) ⬇️
go 6.33% <ø> (ø)
java 54.83% <ø> (ø)
node 92.18% <ø> (-0.15%) ⬇️
python 0.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
core/consensus/src/plane_helpers.rs 56.57% <100.00%> (+36.01%) ⬆️
core/consensus/src/impls.rs 41.52% <92.30%> (+26.13%) ⬆️
core/simulator/src/lib.rs 0.00% <0.00%> (ø)
core/shard/src/lib.rs 0.00% <0.00%> (ø)

... and 19 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The primary was sending PrepareOk to itself through the message
bus, requiring a network round-trip and an unwrap() on bus
errors. Replace with an in-process VecDeque that the simulator
drains after each dispatch. Cleared on view change reset and
on DVC quorum completion.

Includes defensive debug_assert guards on push_loopback
overflow, process_loopback buf precondition, and simulator
drain idempotency. Adds test verifying loopback is cleared
when complete_view_change_as_primary fires.
}

/// Enqueue a self-addressed PrepareOk for the primary to process in the next loopback drain.
pub(crate) fn push_loopback(&self, message: Message<PrepareOkHeader>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't send only PrepareOk to our selves, other messages such as DoViewChange and StartViewChange.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also use that method inside of the send_message_to_replica or however it's called method, when the replica_id == self.replica_id.

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.

3 participants