Merge pull request #1849 from nats-io/raft_fixes

Raft fixes
This commit is contained in:
Derek Collison
2021-01-26 15:29:59 -07:00
committed by GitHub
2 changed files with 22 additions and 10 deletions

View File

@@ -559,6 +559,11 @@ func (n *raft) Applied(index uint64) {
n.Lock()
defer n.Unlock()
// Ignore if already applied.
if index <= n.applied {
return
}
// FIXME(dlc) - Check spec on error conditions, storage
n.applied = index
// FIXME(dlc) - Can be more efficient here.
@@ -1319,6 +1324,10 @@ func (n *raft) loadEntry(index uint64) (*appendEntry, error) {
// applyCommit will update our commit index and apply the entry to the apply chan.
// lock should be held.
func (n *raft) applyCommit(index uint64) {
if index <= n.commit {
n.debug("Ignoring apply commit for %d, already processed", index)
return
}
original := n.commit
n.commit = index

View File

@@ -1378,13 +1378,23 @@ func (s *Server) fetchAccount(name string) (*Account, error) {
// Start up the server, this will block.
// Start via a Go routine if needed.
func (s *Server) Start() {
s.Noticef("Starting nats-server version %s", VERSION)
s.Debugf("Go build version %s", s.info.GoVersion)
s.Noticef("Starting nats-server")
gc := gitCommit
if gc == "" {
gc = "not set"
}
s.Noticef("Git commit [%s]", gc)
s.Noticef(" Version: %s", VERSION)
s.Noticef(" Git: [%s]", gc)
s.Debugf(" Go build: %s", s.info.GoVersion)
s.Noticef(" Name: %s", s.info.Name)
if s.sys != nil {
s.Noticef(" Node: %s", s.sys.shash)
}
s.Noticef(" ID: %s", s.info.ID)
defer s.Noticef("Server is ready")
// Check for insecure configurations.
s.checkAuthforWarnings()
@@ -1769,13 +1779,6 @@ func (s *Server) AcceptLoop(clr chan struct{}) {
return
}
s.Noticef("Server name: %s", s.info.Name)
if s.sys != nil {
s.Noticef("Server node: %s", s.sys.shash)
}
s.Noticef("Server ID: %s", s.info.ID)
s.Noticef("Server is ready")
hp := net.JoinHostPort(opts.Host, strconv.Itoa(opts.Port))
l, e := natsListen("tcp", hp)
if e != nil {