Commit f4ac801f authored by Sushant Mahajan's avatar Sushant Mahajan

fixed logical error in reading log persistence file

parent 93b1a277
...@@ -147,6 +147,7 @@ func (rft *Raft) persistLog() { ...@@ -147,6 +147,7 @@ func (rft *Raft) persistLog() {
} }
func (rft *Raft) readLogFromDisk() { func (rft *Raft) readLogFromDisk() {
rft.LogArray = []*LogEntryData{}
if file, err := os.OpenFile(LOG_PERSIST+strconv.Itoa(rft.id), os.O_RDONLY, 0666); err != nil { if file, err := os.OpenFile(LOG_PERSIST+strconv.Itoa(rft.id), os.O_RDONLY, 0666); err != nil {
rft.Info.Println("error reading log persist file") rft.Info.Println("error reading log persist file")
} else { } else {
...@@ -158,7 +159,6 @@ func (rft *Raft) readLogFromDisk() { ...@@ -158,7 +159,6 @@ func (rft *Raft) readLogFromDisk() {
rft.Info.Println("done reading log from file") rft.Info.Println("done reading log from file")
break break
} else { } else {
rft.LogArray = []*LogEntryData{}
rft.LogArray = append(rft.LogArray, &d) rft.LogArray = append(rft.LogArray, &d)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment