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 stability #2111

Merged
merged 5 commits into from
Mar 29, 2015
Merged

Raft stability #2111

merged 5 commits into from
Mar 29, 2015

Conversation

benbjohnson
Copy link
Contributor

Overview

This pull request adds several raft package clean up fixes.

A list of high level changes:

  • Refactor "applied index" into the FSM only - previously this index was shared between the raft.Log and the FSM.
  • Refactor FSM API to implement io.WriterTo and io.ReaderFrom. The "applied index" refactor above altered the API so conforming to a standard API makes this easier to test.
  • Fix resnapshotting in some edge cases scenarios - the tradeoff of the temporary in-memory staging area for Raft entries requires that the snapshot be refetched in some election scenarios.
  • Fix race detection on state loop startup.
  • Fix race condition when setting the incoming stream.
  • Fix edge cases in log truncation & trimming.
  • Fix new term notification in follower & candidate states.

This pull request also documents the various internal fields in raft.Log.

@pauldix
Copy link
Member

pauldix commented Mar 29, 2015

Just did a quick review and LGTM. Although I haven't fully digested it yet, we need to get this in for RC17 so I'll merge and hopefully @otoolep, @corylanou, and @dgnorton can do further review tomorrow.

@@ -352,32 +351,32 @@ func copyFileN(w io.Writer, path string, n int64) (int64, error) {
return io.CopyN(w, f, n)
}

// Restore reads the broker state.
func (b *Broker) Restore(r io.Reader) error {
// ReadFrom reads a broker snapshot from r.
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: describe what the returned int64 is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the number of bytes read but we're not supporting it. It's just an implementation of the io.ReaderFrom interface. We return an error for any partial reads.

pauldix added a commit that referenced this pull request Mar 29, 2015
@pauldix pauldix merged commit cfeee62 into master Mar 29, 2015
@@ -28,10 +28,6 @@ var (
// ErrOutOfDateLog is returned when a candidate's log is not up to date.
ErrOutOfDateLog = errors.New("out of date log")

// ErrUncommittedIndex is returned when a stream is started from an
Copy link
Contributor

Choose a reason for hiding this comment

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

This can't happen anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the stream starts from the highest available index on the leader and the follower will trim its log or re-request a snapshot if needed.

@pauldix pauldix deleted the raft-stability branch March 29, 2015 23:17
@@ -436,6 +523,12 @@ func (l *Log) writeTerm(term uint64) error {
return ioutil.WriteFile(l.termPath(), b, 0666)
}

// setTerm sets the current term if it's higher.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment does not look correct. I don't see any check within the code. It just sets the term unconditionally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed: 947c776

@otoolep
Copy link
Contributor

otoolep commented Mar 29, 2015

I reviewed, most of my feedback is minor.

mark-rushakoff pushed a commit that referenced this pull request Jan 11, 2019
fix(http): return http 400 if request data is invalid
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.

3 participants