Skip to content

Fix rollback-handling in consistency trace validation - #8133

Open
Amaury Chamayou (achamayou) wants to merge 7 commits into
microsoft:mainfrom
achamayou:achamayou-fix-consistency-trace-rollback
Open

Fix rollback-handling in consistency trace validation#8133
Amaury Chamayou (achamayou) wants to merge 7 commits into
microsoft:mainfrom
achamayou:achamayou-fix-consistency-trace-rollback

Conversation

@achamayou

Copy link
Copy Markdown
Member

Before the fix, whenever the trace referenced a view that the model had not created yet, BackfillLedgerBranches created that view by copying the entire previous ledger branch. That assumes every entry from the previous primary survives an election. In reality, only the committed prefix is guaranteed to survive: an uncommitted suffix may be rolled back, and its sequence numbers may then be reused by the new primary.

For example, suppose transaction A commits at 2.10, transaction B executes at 2.11 but is later invalidated, and transaction C executes at 3.11. The old adapter copied B into the reconstructed view-3 branch, making that branch already 11 entries long. The validator requires the branch to contain exactly 10 entries before executing C at sequence 11, and its normal backfill actions can only append entries, not remove the stale suffix. Validation therefore dead-ended and reported TraceMatched as violated, incorrectly rejecting a valid implementation trace.

The fix copies only the source prefix strictly before the next logged sequence number, bounded by the source branch length. This preserves the full branch when an election has no rollback, drops any rolled-back suffix when sequence numbers are reused, and lets the existing per-branch backfill add unknown non-client entries when the source is shorter than required. Applying the same bounded copy repeatedly also handles non-contiguous view jumps, such as moving directly from view 2 to view 5.

When a new primary reuses a sequence number after rollback, copying the entire prior ledger branch retains the invalid suffix and prevents the logged transaction from matching. Copy only the source prefix before the next implementation sequence number, bounded by the source branch length.

Add a deterministic rollback trace that commits 2.10, invalidates 2.11, and reuses sequence 11 in view 3, and run it in continuous verification.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Document in the CI workflow why rollback coverage uses a hard-coded trace rather than a partitions test.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Cover elections without rollback, rollback of two transactions, and a non-contiguous view jump from 2 to 5. Run every checked-in consistency trace through the adapter in continuous verification.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

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.

Pull request overview

This PR updates the TLA+ consistency trace validator to correctly handle elections that roll back an uncommitted suffix and potentially reuse sequence numbers in a new view, preventing valid implementation traces from being incorrectly rejected.

Changes:

  • Fix BackfillLedgerBranches to copy only the committed/known-safe prefix into newly created view branches (bounded by the next logged seqno and source length).
  • Add several deterministic NDJSON traces covering rollback, no-rollback elections, and non-contiguous view jumps.
  • Extend CI to validate all checked-in consistency election traces via TLC trace validation (tv) with a single worker.

Custom instructions used:

  • .github/copilot-instructions.md

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tla/consistency/TraceMultiNodeReads.tla Adjusts branch backfilling logic to avoid copying rolled-back suffix entries into new-view branches.
tla/consistency/traces/rollback_two_transactions.ndjson Adds a trace where an uncommitted suffix is rolled back and seqnos are reused in a new view.
tla/consistency/traces/rollback_same_seqno.ndjson Adds a trace explicitly reusing the same seqno after invalidation/rollback across views.
tla/consistency/traces/election_non_contiguous_view.ndjson Adds a trace that jumps across views (e.g., 2 -> 5) to exercise repeated bounded copying.
tla/consistency/traces/election_no_rollback.ndjson Adds a control trace where the full prior branch remains valid across an election (no rollback).
.github/workflows/ci-verification.yml Validates all checked-in consistency traces in CI using single-worker TLC trace validation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

READY TO MERGE tla TLA+ specifications

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants