Author: eelco
Date: Wed Jul 13 14:05:54 2011
New Revision: 27760
URL: https://svn.nixos.org/websvn/nix/?rev=27760&sc=1
Log:
* Fix concurrency issues in download-using-manifests' handling of the
SQLite manifest cache. The DBI AutoCommit feature caused every
process to have an active transaction at all times, which could
indefinitely block processes wanting to update the manifest cache.
* Disable fsync() in the manifest cache because we don't need
integrity (the cache can always be recreated if it gets corrupted).
Modified:
nix/trunk/scripts/NixManifest.pm.in
nix/trunk/scripts/download-using-manifests.pl.in
Modified: nix/trunk/scripts/NixManifest.pm.in
==============================================================================
--- nix/trunk/scripts/NixManifest.pm.in Wed Jul 13 13:08:49 2011 (r27759)
+++ nix/trunk/scripts/NixManifest.pm.in Wed Jul 13 14:05:54 2011 (r27760)
@@ -219,11 +219,12 @@
# Open/create the database.
our $dbh = DBI->connect("dbi:SQLite:dbname=$dbPath", "", "")
or die "cannot open database `$dbPath'";
- $dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
$dbh->{PrintError} = 0;
$dbh->do("pragma foreign_keys = on");
+ $dbh->do("pragma synchronous = off"); # we can always reproduce the cache
+ $dbh->do("pragma journal_mode = truncate");
# Initialise the database schema, if necessary.
$dbh->do(<<EOF);
@@ -278,6 +279,8 @@
open MAINLOCK, ">>$manifestDir/cache.lock" or die;
flock(MAINLOCK, LOCK_EX) or die;
+ $dbh->begin_work;
+
# Read each manifest in $manifestDir and add it to the database,
# unless we've already done so on a previous run.
my %seen;
@@ -291,6 +294,8 @@
"select 1 from Manifests where path = ? and timestamp = ?",
{}, $manifest, $timestamp)} == 1;
+ print STDERR "caching $manifest...\n";
+
$dbh->do("delete from Manifests where path = ?", {}, $manifest);
$dbh->do("insert into Manifests(path, timestamp) values (?, ?)",
Modified: nix/trunk/scripts/download-using-manifests.pl.in
==============================================================================
--- nix/trunk/scripts/download-using-manifests.pl.in Wed Jul 13 13:08:49
2011 (r27759)
+++ nix/trunk/scripts/download-using-manifests.pl.in Wed Jul 13 14:05:54
2011 (r27760)
@@ -267,6 +267,12 @@
die "don't know how to produce $targetPath\n" if scalar @path == 0;
+# We don't need the manifest anymore, so close it as an optimisation:
+# if we still have SQLite locks blocking other processes (we
+# shouldn't), this gets rid of them.
+$dbh->disconnect;
+
+
# Traverse the shortest path, perform the actions described by the
# edges.
my $curStep = 1;
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits