From d34c35df31f425517c4df2d8d8609ea9b82198a5 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Sun, 15 Oct 2023 21:09:25 -0400 Subject: [PATCH] No need to Store-level WAL selection --- store/db_config.go | 3 --- store/store.go | 20 +++++++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/store/db_config.go b/store/db_config.go index 384c60b9..b79b7a3f 100644 --- a/store/db_config.go +++ b/store/db_config.go @@ -7,9 +7,6 @@ type DBConfig struct { // Enforce Foreign Key constraints FKConstraints bool `json:"fk_constraints"` - - // Disable WAL mode if running in on-disk mode - DisableWAL bool `json:"disable_wal"` } // NewDBConfig returns a new DB config instance. diff --git a/store/store.go b/store/store.go index 9021fbd7..ca17f773 100644 --- a/store/store.go +++ b/store/store.go @@ -437,7 +437,7 @@ func (s *Store) Open() (retErr error) { s.logger.Printf("first log index: %d, last log index: %d, last applied index: %d, last command log index: %d:", s.firstIdxOnOpen, s.lastIdxOnOpen, s.lastAppliedIdxOnOpen, s.lastCommandIdxOnOpen) - s.db, err = createOnDisk(nil, s.dbPath, s.dbConf.FKConstraints, !s.dbConf.DisableWAL) + s.db, err = createOnDisk(nil, s.dbPath, s.dbConf.FKConstraints, true) if err != nil { return fmt.Errorf("failed to create on-disk database: %s", err) } @@ -566,18 +566,16 @@ func (s *Store) Close(wait bool) (retErr error) { return err } - // If in WAL mode, open-and-close again to remove the -wal file. This is not + // Open-and-close again to remove the -wal file. This is not // strictly necessary, since any on-disk database files will be removed when // rqlite next starts, but it leaves the directory containing the database // file in a cleaner state. - if !s.dbConf.DisableWAL { - walDB, err := sql.Open(s.dbPath, s.dbConf.FKConstraints, true) - if err != nil { - return err - } - if err := walDB.Close(); err != nil { - return err - } + walDB, err := sql.Open(s.dbPath, s.dbConf.FKConstraints, true) + if err != nil { + return err + } + if err := walDB.Close(); err != nil { + return err } return nil @@ -1733,7 +1731,7 @@ func (s *Store) Restore(rc io.ReadCloser) error { } var db *sql.DB - db, err = sql.Open(s.dbPath, s.dbConf.FKConstraints, !s.dbConf.DisableWAL) + db, err = sql.Open(s.dbPath, s.dbConf.FKConstraints, true) if err != nil { return fmt.Errorf("open SQLite file during restore: %s", err) }