Undo bad commit for raft.go

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2022-12-06 05:30:49 -08:00
parent 0fd8ad6905
commit 381be704e0

View File

@@ -25,7 +25,6 @@ import (
"net"
"os"
"path/filepath"
"strings"
"sync"
"sync/atomic"
"time"
@@ -952,12 +951,6 @@ func (n *raft) InstallSnapshot(data []byte) error {
return errCatchupsRunning
}
// We don't store snapshotsnfor memory based WALs.
if _, ok := n.wal.(*memStore); ok {
n.Unlock()
return nil
}
var state StreamState
n.wal.FastState(&state)
@@ -966,20 +959,6 @@ func (n *raft) InstallSnapshot(data []byte) error {
return nil
}
if len(data) == 0 {
if strings.HasPrefix(n.group, "C-") {
fmt.Printf("\n\n%v state is %+v, n.applied is %d, n.snapfile is %q\n", n.group, state, n.applied, n.snapfile)
for index := state.FirstSeq; index <= state.LastSeq; index++ {
ae, _ := n.loadEntry(index)
for _, e := range ae.entries {
fmt.Printf("Entry %+v\n", e)
}
}
n.Unlock()
panic("XXX")
}
}
n.debug("Installing snapshot of %d bytes", len(data))
var term uint64
@@ -1102,10 +1081,8 @@ func (n *raft) setupLastSnapshot() {
n.snapfile = latest
snap, err := n.loadLastSnapshot()
if err != nil {
if n.snapfile != _EMPTY_ {
os.Remove(n.snapfile)
n.snapfile = _EMPTY_
}
os.Remove(n.snapfile)
n.snapfile = _EMPTY_
} else {
n.pindex = snap.lastIndex
n.pterm = snap.lastTerm