1
0
Fork 0

Merge pull request #756 from rqlite/fix-ineff

Fix on-disk create in Apply
master
Philip O'Toole 4 years ago committed by GitHub
commit a41348e230
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 // *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 // 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 // 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() b, err := s.db.Serialize()
if err != nil { if err != nil {
e = &fsmGenericResponse{error: fmt.Errorf("serialize failed: %s", err)} 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. // Open a new on-disk database.
s.db, err = s.openOnDisk(b) 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)} e = &fsmGenericResponse{error: fmt.Errorf("open on-disk failed: %s", err)}
return
} }
s.onDiskCreated = true s.onDiskCreated = true
s.logger.Println("successfully switched to on-disk database") s.logger.Println("successfully switched to on-disk database")

Loading…
Cancel
Save