Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raft: fix correctness bug in CommittedEntries pagination #10063

Merged
merged 1 commit into from
Oct 2, 2018

Commits on Sep 4, 2018

  1. raft: fix correctness bug in CommittedEntries pagination

    In etcd-io#9982, a mechanism to limit the size of `CommittedEntries` was
    introduced. The way this mechanism worked was that it would load
    applicable entries (passing the max size hint) and would emit a
    `HardState` whose commit index was truncated to match the limitation
    applied to the entries. Unfortunately, this was subtly incorrect
    when the user-provided `Entries` implementation didn't exactly
    match what Raft uses internally. Depending on whether a `Node` or
    a `RawNode` was used, this would either lead to regressing the
    HardState's commit index or outright forgetting to apply entries,
    respectively.
    
    Asking implementers to precisely match the Raft size limitation
    semantics was considered but looks like a bad idea as it puts
    correctness squarely in the hands of downstream users. Instead, this
    PR removes the truncation of `HardState` when limiting is active
    and tracks the applied index separately. This removes the old
    paradigm (that the previous code tried to work around) that the
    client will always apply all the way to the commit index, which
    isn't true when commit entries are paginated.
    
    See [1] for more on the discovery of this bug (CockroachDB's
    implementation of `Entries` returns one more entry than Raft's when the
    size limit hits).
    
    [1]: cockroachdb/cockroach#28918 (comment)
    tbg committed Sep 4, 2018
    Configuration menu
    Copy the full SHA
    7a8ab37 View commit details
    Browse the repository at this point in the history