1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-02 21:51:50 +02:00

* Disable fsync() in SQLite if the fsync-metadata option is set to

false.
* Change the default for `fsync-metadata' to true.
* Disable `fsync-metadata' in `make check'.
This commit is contained in:
Eelco Dolstra 2010-02-24 13:12:57 +00:00
parent 90b6352d0a
commit a3c63d0d6c
4 changed files with 9 additions and 9 deletions

View file

@ -219,9 +219,13 @@ LocalStore::LocalStore()
/* !!! check whether sqlite has been built with foreign key
support */
/* "Normal" synchronous mode should be safe enough. */
if (sqlite3_exec(db, "pragma synchronous = normal;", 0, 0, 0) != SQLITE_OK)
throw SQLiteError(db, "changing synchronous mode to normal");
/* Whether SQLite should fsync(). "Normal" synchronous mode
should be safe enough. If the user asks for it, don't sync at
all. This can cause database corruption if the system
crashes. */
string syncMode = queryBoolSetting("fsync-metadata", true) ? "normal" : "off";
if (sqlite3_exec(db, ("pragma synchronous = " + syncMode + ";").c_str(), 0, 0, 0) != SQLITE_OK)
throw SQLiteError(db, "setting synchronous mode");
/* Check the current database schema and if necessary do an
upgrade. !!! Race condition: several processes could start
@ -243,8 +247,6 @@ LocalStore::LocalStore()
"please upgrade Nix to version 0.12 first.");
else if (curSchema < 6) upgradeStore6();
else prepareStatements();
doFsync = queryBoolSetting("fsync-metadata", false);
}

View file

@ -191,9 +191,6 @@ private:
/* Lock file used for upgrading. */
AutoCloseFD globalLock;
/* Whether to do an fsync() after writing Nix metadata. */
bool doFsync;
/* The SQLite database object. */
SQLite db;