Remove Hydra::Helper::nix::txn_do from the Perl code
To quote the function's comment: 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. Since SQLite is now dropped entirely, this wrapper can be removed completely.
This commit is contained in:
@ -46,7 +46,7 @@ sub updateDeclarativeJobset {
|
||||
$update{$key} = $declSpec->{$key};
|
||||
delete $declSpec->{$key};
|
||||
}
|
||||
txn_do($db, sub {
|
||||
$db->txn_do(sub {
|
||||
my $jobset = $project->jobsets->update_or_create(\%update);
|
||||
$jobset->jobsetinputs->delete;
|
||||
while ((my $name, my $data) = each %{$declSpec->{"inputs"}}) {
|
||||
@ -79,7 +79,7 @@ sub handleDeclarativeJobsetBuild {
|
||||
}
|
||||
|
||||
my $declSpec = decode_json($declText);
|
||||
txn_do($db, sub {
|
||||
$db->txn_do(sub {
|
||||
my @kept = keys %$declSpec;
|
||||
push @kept, ".jobsets";
|
||||
$project->jobsets->search({ name => { "not in" => \@kept } })->update({ enabled => 0, hidden => 1 });
|
||||
|
@ -14,7 +14,7 @@ use IPC::Run;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(
|
||||
getHydraHome getHydraConfig getBaseUrl txn_do
|
||||
getHydraHome getHydraConfig getBaseUrl
|
||||
getSCMCacheDir
|
||||
registerRoot getGCRootsDir gcRootFor
|
||||
jobsetOverview jobsetOverview_
|
||||
@ -61,22 +61,6 @@ sub getBaseUrl {
|
||||
}
|
||||
|
||||
|
||||
# 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) = @_;
|
||||
my $res;
|
||||
while (1) {
|
||||
eval {
|
||||
$res = $db->txn_do($coderef);
|
||||
};
|
||||
return $res if !$@;
|
||||
die $@ unless $@ =~ "database is locked";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub getSCMCacheDir {
|
||||
return Hydra::Model::DB::getHydraPath . "/scm" ;
|
||||
}
|
||||
@ -446,7 +430,7 @@ sub getTotalShares {
|
||||
|
||||
sub cancelBuilds($$) {
|
||||
my ($db, $builds) = @_;
|
||||
return txn_do($db, sub {
|
||||
return $db->txn_do(sub {
|
||||
$builds = $builds->search({ finished => 0 });
|
||||
my $n = $builds->count;
|
||||
my $time = time();
|
||||
@ -473,7 +457,7 @@ sub restartBuilds($$) {
|
||||
|
||||
my $nrRestarted = 0;
|
||||
|
||||
txn_do($db, sub {
|
||||
$db->txn_do(sub {
|
||||
# Reset the stats for the evals to which the builds belongs.
|
||||
# !!! Should do this in a trigger.
|
||||
$db->resultset('JobsetEvals')->search(
|
||||
|
Reference in New Issue
Block a user