* 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

@ -65,7 +65,7 @@ sub doBuild {
if (/^@\s+build-started\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/) {
my $drvPathStep = $1;
$db->txn_do(sub {
txn_do($db, sub {
$build->buildsteps->create(
{ stepnr => ($buildSteps{$drvPathStep} = $buildStepNr++)
, type => 0 # = build
@ -80,7 +80,7 @@ sub doBuild {
elsif (/^@\s+build-succeeded\s+(\S+)\s+(\S+)$/) {
my $drvPathStep = $1;
$db->txn_do(sub {
txn_do($db, sub {
my $step = $build->buildsteps->find({stepnr => $buildSteps{$drvPathStep}}) or die;
$step->update({busy => 0, status => 0, stoptime => time});
});
@ -92,7 +92,7 @@ sub doBuild {
$thisBuildFailed = 1 if $drvPath eq $drvPathStep;
my $errorMsg = $4;
$errorMsg = "build failed previously (cached)" if $3 eq "cached";
$db->txn_do(sub {
txn_do($db, sub {
if ($buildSteps{$drvPathStep}) {
my $step = $build->buildsteps->find({stepnr => $buildSteps{$drvPathStep}}) or die;
$step->update({busy => 0, status => 1, errormsg => $errorMsg, stoptime => time});
@ -119,7 +119,7 @@ sub doBuild {
elsif (/^@\s+substituter-started\s+(\S+)\s+(\S+)$/) {
my $outPath = $1;
$db->txn_do(sub {
txn_do($db, sub {
$build->buildsteps->create(
{ stepnr => ($buildSteps{$outPath} = $buildStepNr++)
, type => 1 # = substitution
@ -132,7 +132,7 @@ sub doBuild {
elsif (/^@\s+substituter-succeeded\s+(\S+)$/) {
my $outPath = $1;
$db->txn_do(sub {
txn_do($db, sub {
my $step = $build->buildsteps->find({stepnr => $buildSteps{$outPath}}) or die;
$step->update({busy => 0, status => 0, stoptime => time});
});
@ -140,7 +140,7 @@ sub doBuild {
elsif (/^@\s+substituter-failed\s+(\S+)\s+(\S+)\s+(\S+)$/) {
my $outPath = $1;
$db->txn_do(sub {
txn_do($db, sub {
my $step = $build->buildsteps->find({stepnr => $buildSteps{$outPath}}) or die;
$step->update({busy => 0, status => 1, errormsg => $3, stoptime => time});
});
@ -169,7 +169,7 @@ sub doBuild {
done:
$db->txn_do(sub {
txn_do($db, sub {
$build->update({finished => 1, timestamp => time});
my $releaseName;
@ -265,7 +265,7 @@ print STDERR "performing build $buildId\n";
# children (i.e. the build.pl instances) can continue to run and won't
# have the lock taken away.
my $build;
$db->txn_do(sub {
txn_do($db, sub {
$build = $db->resultset('Builds')->find($buildId);
die "build $buildId doesn't exist" unless defined $build;
die "build $buildId already done" if defined $build->resultInfo;
@ -287,7 +287,7 @@ eval {
};
if ($@) {
warn $@;
$db->txn_do(sub {
txn_do($db, sub {
$build->schedulingInfo->update({busy => 0, locker => $$});
});
}

View File

@ -19,7 +19,7 @@ die "The HYDRA_HOME environment variable is not set!\n" unless defined $hydraHom
sub unlockDeadBuilds {
# Unlock builds whose building process has died.
$db->txn_do(sub {
txn_do($db, sub {
my @builds = $db->resultset('Builds')->search(
{finished => 0, busy => 1}, {join => 'schedulingInfo'});
foreach my $build (@builds) {
@ -54,7 +54,7 @@ sub checkBuilds {
my @buildsStarted;
$db->txn_do(sub {
txn_do($db, sub {
# Get the system types for the runnable builds.
my @systemTypes = $db->resultset('Builds')->search(
@ -123,7 +123,7 @@ sub checkBuilds {
};
if ($@) {
warn $@;
$db->txn_do(sub {
txn_do($db, sub {
$build->schedulingInfo->busy(0);
$build->schedulingInfo->locker($$);
$build->schedulingInfo->update;

View File

@ -111,7 +111,7 @@ sub fetchInputAlt {
# but if it doesn't change (or changes back), we don't get
# a new "revision".
if (!defined $cachedInput) {
$db->txn_do(sub {
txn_do($db, sub {
$db->resultset('CachedPathInputs')->create(
{ srcpath => $uri
, timestamp => $timestamp
@ -122,7 +122,7 @@ sub fetchInputAlt {
});
} else {
$timestamp = $cachedInput->timestamp;
$db->txn_do(sub {
txn_do($db, sub {
$cachedInput->update({lastseen => time});
});
}
@ -170,7 +170,7 @@ sub fetchInputAlt {
($sha256, $storePath) = split ' ', $stdout;
$db->txn_do(sub {
txn_do($db, sub {
$db->resultset('CachedSubversionInputs')->create(
{ uri => $uri
, revision => $revision
@ -260,7 +260,7 @@ sub checkJob {
$priority = int($job->{schedulingPriority})
if $job->{schedulingPriority} =~ /^\d+$/;
$db->txn_do(sub {
txn_do($db, sub {
# Mark this job as active in the database.
my $jobInDB = $jobset->jobs->update_or_create(
{ name => $jobName
@ -326,7 +326,7 @@ sub checkJob {
sub setJobsetError {
my ($jobset, $errorMsg) = @_;
eval {
$db->txn_do(sub {
txn_do($db, sub {
$jobset->update({errormsg => $errorMsg, errortime => time});
});
};
@ -370,9 +370,10 @@ sub checkJobset {
fetchInputs($project, $jobset, $inputInfo);
# Evaluate the job expression.
die "not supported" if scalar @{$inputInfo->{$jobset->nixexprinput}} != 1;
my $nixExprInput = $inputInfo->{$jobset->nixexprinput}->[0]
or die "cannot find the input containing the job expression";
die "multiple alternatives for the input containing the Nix expression are not supported"
if scalar @{$inputInfo->{$jobset->nixexprinput}} != 1;
my $nixExprPath = $nixExprInput->{storePath} . "/" . $jobset->nixexprpath;
(my $res, my $jobsXml, my $stderr) = captureStdoutStderr(
@ -402,7 +403,7 @@ sub checkJobset {
my %failedJobNames;
push @{$failedJobNames{$_->{location}}}, $_->{msg} foreach @{$jobs->{error}};
$db->txn_do(sub {
txn_do($db, sub {
$jobset->update({lastcheckedtime => time});
foreach my $jobInDB ($jobset->jobs->all) {
@ -448,7 +449,7 @@ sub checkJobsetWrapped {
if ($@) {
my $msg = $@;
print "error evaluating jobset ", $jobset->name, ": $msg";
$db->txn_do(sub {
txn_do($db, sub {
$jobset->update({lastcheckedtime => time});
setJobsetError($jobset, $msg);
});