* Hack around those SQLite timeouts: just retry the transaction.

This commit is contained in:
Eelco Dolstra
2009-04-22 22:43:04 +00:00
parent 80691a39f5
commit 97a6011628
8 changed files with 49 additions and 33 deletions

View File

@ -8,7 +8,7 @@ use File::Basename;
our @ISA = qw(Exporter);
our @EXPORT = qw(
isValidPath queryPathInfo
getHydraPath getHydraDBPath openHydraDB
getHydraPath getHydraDBPath openHydraDB txn_do
registerRoot getGCRootsDir gcRootFor
getPrimaryBuildsForReleaseSet getRelease getLatestSuccessfulRelease );
@ -78,6 +78,21 @@ sub openHydraDB {
}
# Awful hack to handle timeouts in SQLite: just retry the transaction.
# DBD::SQLite *has* a 30 second retry window, but apparently it
# doesn't work.
sub txn_do {
my ($db, $coderef) = @_;
while (1) {
eval {
$db->txn_do($coderef);
};
last if !$@;
die $@ unless $@ =~ "database is locked";
}
}
sub getGCRootsDir {
die unless defined $ENV{LOGNAME};
my $dir = "/nix/var/nix/gcroots/per-user/$ENV{LOGNAME}/hydra-roots";