* 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

@ -241,7 +241,7 @@ build-use-chroot = /dev /proc /bin</programlisting>
Nix store metadata (in <filename>/nix/var/nix/db</filename>) are Nix store metadata (in <filename>/nix/var/nix/db</filename>) are
synchronously flushed to disk. This improves robustness in case synchronously flushed to disk. This improves robustness in case
of system crashes, but reduces performance. The default is of system crashes, but reduces performance. The default is
<literal>false</literal>.</para></listitem> <literal>true</literal>.</para></listitem>
</varlistentry> </varlistentry>

View File

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

View File

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

View File

@ -40,6 +40,7 @@ cat > "$NIX_CONF_DIR"/nix.conf <<EOF
gc-keep-outputs = false gc-keep-outputs = false
gc-keep-derivations = false gc-keep-derivations = false
env-keep-derivations = false env-keep-derivations = false
fsync-metadata = false
EOF EOF
mkdir $NIX_DATA_DIR/nix mkdir $NIX_DATA_DIR/nix