diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-02-24T13·12+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-02-24T13·12+0000 |
commit | a3c63d0d6c2570ce3218be809f67dddc5239cdff (patch) | |
tree | 1d062729d423c96c133c291ff01acb11c2e933d9 | |
parent | 90b6352d0a5d08dc7feabcfde92653dd1f6e324b (diff) |
* 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'.
-rw-r--r-- | doc/manual/conf-file.xml | 2 | ||||
-rw-r--r-- | src/libstore/local-store.cc | 12 | ||||
-rw-r--r-- | src/libstore/local-store.hh | 3 | ||||
-rw-r--r-- | tests/init.sh | 1 |
4 files changed, 9 insertions, 9 deletions
diff --git a/doc/manual/conf-file.xml b/doc/manual/conf-file.xml index 2ee268097066..19e86808ec3a 100644 --- a/doc/manual/conf-file.xml +++ b/doc/manual/conf-file.xml @@ -241,7 +241,7 @@ build-use-chroot = /dev /proc /bin</programlisting> Nix store metadata (in <filename>/nix/var/nix/db</filename>) are synchronously flushed to disk. This improves robustness in case of system crashes, but reduces performance. The default is - <literal>false</literal>.</para></listitem> + <literal>true</literal>.</para></listitem> </varlistentry> diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 6e8082776dd0..67a91bb49f65 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -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); } diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index 1a4acbe0e4eb..ec0b482eae3e 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -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; diff --git a/tests/init.sh b/tests/init.sh index 691cb669b72c..64947031bfe7 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -40,6 +40,7 @@ cat > "$NIX_CONF_DIR"/nix.conf <<EOF gc-keep-outputs = false gc-keep-derivations = false env-keep-derivations = false +fsync-metadata = false EOF mkdir $NIX_DATA_DIR/nix |