-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
142016: logstore: load last entry term r=tbg a=pav-kv We already [read](https://github.com/cockroachdb/cockroach/blob/19290ae07afa1a296fca9eee9f77d2e9c60eb804/pkg/raft/log.go#L102-L106) the last entry term when initializing `RawNode`, so there is no additional overhead, except the fact that this entry is now not stashed into the raft entry cache. There appears to be low benefit in putting it into the cache though. Typically, we wouldn't need exactly the `LastIndex` entry post startup, it would more likely be an earlier entry or a future one. So putting `LastIndex` into the cache early on actually makes it ineffective because the cache [drops](https://github.com/cockroachdb/cockroach/blob/19290ae07afa1a296fca9eee9f77d2e9c60eb804/pkg/kv/kvserver/raftentry/ring_buffer.go#L207-L209) entries below the cached slice. Eventually, on startup we will load the term cache instead of the last entry. As a nice side-effect, this PR removes the `invalidLastTerm` oddity. It also introduces an invariant that `Replica` always knows the last raft log entry index/term. A panic [here](https://github.com/cockroachdb/cockroach/blob/19290ae07afa1a296fca9eee9f77d2e9c60eb804/pkg/raft/log.go#L102-L106) can be removed too, with an API tweak (not doing here). Resolves #142013 Co-authored-by: Pavel Kalinnikov <[email protected]>
- Loading branch information
Showing
9 changed files
with
53 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters