Skip to content

bft: hold the view while the view changer writes - #745

Merged
HagarMeir merged 1 commit into
hyperledger:mainfrom
pfi79:735-4c-view-changer-hold
Nov 2, 2026
Merged

HagarMeir merged 1 commit into
hyperledger:mainfrom
pfi79:735-4c-view-changer-hold

Conversation

@pfi79

@pfi79 pfi79 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

The view changer saved a ViewChange or NewView record after AbortView returned, but the controller could restart the view through the sync path before the record was written. A commit could then land after the record and leave a WAL sequence that recovery rejects.

Add AbortViewAndHold and ReleaseViewWrite, and let the view changer hold viewTransitionLock from the abort until its record is saved. changeView also takes the lock. A stale view change or new view is rejected instead of writing over a newer view.

AbortViewAndHold keeps the cancel channel that AbortView uses, so stopping the view changer still cannot hang on a reconfiguration lock.

#736

return &holdTestProposer{}, COMMITTED
}

func TestAbortViewAndHoldBlocksViewChangesUntilReleased(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this test go in controller_abort_view_test.go? It's the same package and topic, and that file already has newAbortTestView, abortTestBatcher and abortTestLeaderMonitor. holdTestProposer looks like it could be a View from newAbortTestView.

(Written by Claude Code.)

Comment thread internal/bft/viewchanger.go Outdated
Comment on lines +475 to +477
// A view change record is not a truncation point in this change: the
// proposal in flight, if there is one, travels in the view data message
// and must stay recoverable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: "is not a truncation point in this change" (here and at L1258) will read oddly once this is merged, because "this change" won't mean anything in the code. Maybe "is not a truncation point" plus the reason?

(Written by Claude Code.)

The view changer saved a ViewChange or NewView record after AbortView
returned, but the controller could restart the view through the sync path
before the record was written. A commit could then land after the record
and leave a WAL sequence that recovery rejects.

Add AbortViewAndHold and ReleaseViewWrite, and let the view changer hold
viewTransitionLock from the abort until its record is saved. changeView also
takes the lock. A stale view change or new view is rejected instead of
writing over a newer view.

AbortViewAndHold keeps the cancel channel that AbortView uses, so stopping
the view changer still cannot hang on a reconfiguration lock.

Signed-off-by: Fedor Partanskiy <fredprtnsk@gmail.com>
@pfi79
pfi79 force-pushed the 735-4c-view-changer-hold branch from 7440d2e to 726c82a Compare November 2, 2026 09:17
@pfi79

pfi79 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

fixed

@HagarMeir
HagarMeir merged commit 2b9edf4 into hyperledger:main Nov 2, 2026
6 checks passed
@pfi79
pfi79 deleted the 735-4c-view-changer-hold branch November 2, 2026 09:24
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.

2 participants