From 0b84667b45dd69640390a5a1547d24d15673b897 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Wed, 3 Feb 2021 12:01:55 -0500 Subject: [PATCH] Fix on-disk create in Apply --- store/store.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/store/store.go b/store/store.go index bd787f3e..7bac4078 100644 --- a/store/store.go +++ b/store/store.go @@ -968,7 +968,7 @@ func (s *Store) Apply(l *raft.Log) (e interface{}) { // *and* there were commands in the log. A snapshot may or may not have // been applied, but it wouldn't have created the on-disk database in that // case since there were commands in the log. This is the very last chance - // to do it. + // to do convert from in-memory to on-disk. b, err := s.db.Serialize() if err != nil { e = &fsmGenericResponse{error: fmt.Errorf("serialize failed: %s", err)} @@ -980,8 +980,9 @@ func (s *Store) Apply(l *raft.Log) (e interface{}) { } // Open a new on-disk database. s.db, err = s.openOnDisk(b) - if err := ioutil.WriteFile(s.dbPath, b, 0660); err != nil { + if err != nil { e = &fsmGenericResponse{error: fmt.Errorf("open on-disk failed: %s", err)} + return } s.onDiskCreated = true s.logger.Println("successfully switched to on-disk database")