mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +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:
parent
90b6352d0a
commit
a3c63d0d6c
4 changed files with 9 additions and 9 deletions
|
@ -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>
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue