summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinfra/dgit-repos-policy-debian29
1 files changed, 21 insertions, 8 deletions
diff --git a/infra/dgit-repos-policy-debian b/infra/dgit-repos-policy-debian
index e665a63..5d843a0 100755
--- a/infra/dgit-repos-policy-debian
+++ b/infra/dgit-repos-policy-debian
@@ -452,21 +452,34 @@ if (!$fn) {
my $sleepy=0;
my $rcode;
+my $db_busy_exception= 'Debian::Dgit::Policy::Debian::DB_BUSY';
+
+my @orgargv = @ARGV;
+
for (;;) {
- poldb_setup(poldb_path($repos));
- $stderr = '';
+ @ARGV = @orgargv;
+ eval {
+ poldb_setup(poldb_path($repos));
+ $stderr = '';
+
+ $poldbh->{HandleError} = sub {
+ return 0 unless $poldbh->err == 5; # SQLITE_BUSY, not in .pm :-(
+ die bless { }, $db_busy_exception;
+ };
- $rcode = $fn->();
- die unless defined $rcode;
+ $rcode = $fn->();
+ die unless defined $rcode;
- eval { $poldbh->commit; };
+ $poldbh->commit;
+ };
last unless length $@;
+ die $@ unless ref $@ eq $db_busy_exception;
die if $sleepy >= 20;
- print STDERR "[policy database busy, retrying]\n";
- sleep ++$sleepy;
+ $sleepy++;
+ print STDERR "[policy database busy, retrying (${sleepy}s)]\n";
- $poldbh->rollback;
+ eval { $poldbh->rollback; };
}
print STDERR $stderr or die $!;