Skip to content
New issue

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

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

Already on GitHub? # to your account

64-bit align replication counters #344

Merged
merged 2 commits into from
Jul 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ var (
// followerReplication is in charge of sending snapshots and log entries from
// this leader during this particular term to a remote follower.
type followerReplication struct {
// currentTerm and nextIndex must be kept at the top of the struct so
// they're 64 bit aligned which is a requirement for atomic ops on 32 bit
// platforms.

// currentTerm is the term of this leader, to be included in AppendEntries
// requests.
currentTerm uint64

// nextIndex is the index of the next log entry to send to the follower,
// which may fall past the end of the log.
nextIndex uint64

// peer contains the network address and ID of the remote follower.
peer Server

Expand All @@ -49,14 +61,6 @@ type followerReplication struct {
// deferErr, the sender can be notifed when the replication is done.
triggerDeferErrorCh chan *deferError

// currentTerm is the term of this leader, to be included in AppendEntries
// requests.
currentTerm uint64

// nextIndex is the index of the next log entry to send to the follower,
// which may fall past the end of the log.
nextIndex uint64

// lastContact is updated to the current time whenever any response is
// received from the follower (successful or not). This is used to check
// whether the leader should step down (Raft.checkLeaderLease()).
Expand Down