line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::TryAgain::st; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
108
|
|
4
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
2242
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our @ISA = 'DBI::st'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _should_try_again { |
9
|
16
|
|
|
16
|
|
45
|
my $self = shift; |
10
|
16
|
|
100
|
|
|
205
|
my $tried = $self->{private_dbix_try_again_tries} || 0; |
11
|
16
|
100
|
|
|
|
159
|
return 0 if $tried >= $self->{private_dbix_try_again_max_retries}; |
12
|
12
|
|
|
|
|
34
|
for my $msg ( @{ $self->{private_dbix_try_again_on_messages} } ) { |
|
12
|
|
|
|
|
90
|
|
13
|
12
|
50
|
|
|
|
462
|
if ($self->errstr =~ $msg) { |
14
|
12
|
|
|
|
|
263
|
DBI->trace_msg("DBIx::TryAgain [$$] error string ".$self->errstr." matches $msg, will try again.\n"); |
15
|
12
|
|
|
|
|
83
|
return 1; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
} |
18
|
0
|
|
|
|
|
0
|
return 0; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _sleep { |
22
|
16
|
|
|
16
|
|
633
|
my $self = shift; |
23
|
16
|
|
|
|
|
28
|
my $init = shift; |
24
|
16
|
100
|
|
|
|
62
|
if ($init) { |
25
|
4
|
|
|
|
|
48
|
$self->{private_dbix_try_again_tries} = 0; |
26
|
4
|
|
|
|
|
40
|
$self->{private_dbix_try_again_slept} = []; |
27
|
4
|
|
|
|
|
17
|
return; |
28
|
|
|
|
|
|
|
} |
29
|
12
|
|
|
|
|
70
|
my $tried = $self->{private_dbix_try_again_tries}; |
30
|
12
|
|
|
|
|
67
|
my $slept = $self->{private_dbix_try_again_slept}; |
31
|
12
|
|
|
|
|
83
|
my $alg = $self->{private_dbix_try_again_algorithm}; |
32
|
12
|
50
|
66
|
|
|
188
|
my $delay = |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$tried == 1 ? 1 |
34
|
|
|
|
|
|
|
: $tried == 2 && $alg eq 'fibonacci' ? 1 |
35
|
|
|
|
|
|
|
: $alg eq 'constant' ? $slept->[-1] |
36
|
|
|
|
|
|
|
: $alg eq 'linear' ? $slept->[-1] + 1 |
37
|
|
|
|
|
|
|
: $alg eq 'exponential' ? $slept->[-1] * 2 |
38
|
|
|
|
|
|
|
: $alg eq 'fibonacci' ? $slept->[-1] + $slept->[-2] |
39
|
|
|
|
|
|
|
: die "unknown backoff algorithm : $alg"; |
40
|
|
|
|
|
|
|
|
41
|
12
|
|
|
|
|
33
|
push @$slept, $delay; |
42
|
|
|
|
|
|
|
|
43
|
12
|
|
|
|
|
62
|
for ("DBIx::TryAgain [$$] sleeping $delay") { |
44
|
12
|
|
|
|
|
40
|
DBI->trace_msg($_); |
45
|
12
|
50
|
|
|
|
113
|
warn $_ if $self->{PrintError}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
12
|
|
|
|
|
16014500
|
sleep $delay; |
49
|
12
|
|
|
|
|
239
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub execute { |
53
|
6
|
|
|
6
|
0
|
534
|
my $self = shift; |
54
|
6
|
|
|
|
|
24201
|
my $res = $self->SUPER::execute(@_); |
55
|
6
|
100
|
|
|
|
37
|
return $res if $res; |
56
|
2
|
|
|
|
|
10
|
$self->_sleep('init'); |
57
|
2
|
|
|
|
|
12
|
$self->{private_dbix_try_again_tries} = 0; |
58
|
2
|
|
|
|
|
9
|
while ($self->_should_try_again) { |
59
|
6
|
|
|
|
|
255
|
$self->{private_dbix_try_again_tries}++; |
60
|
|
|
|
|
|
|
|
61
|
6
|
|
|
|
|
82
|
for ("DBIx::TryAgain [$$] execute attempt number ".$self->{private_dbix_try_again_tries}."\n") { |
62
|
6
|
|
|
|
|
21
|
DBI->trace_msg($_); |
63
|
6
|
50
|
|
|
|
78
|
warn $_ if $self->{PrintError}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
6
|
|
|
|
|
24
|
$self->_sleep; |
67
|
6
|
|
|
|
|
274
|
$self->set_err(undef, undef); |
68
|
6
|
|
|
|
|
7084
|
$res = $self->SUPER::execute(@_); |
69
|
6
|
50
|
|
|
|
90
|
return $res if $res; |
70
|
|
|
|
|
|
|
} |
71
|
2
|
|
|
|
|
21
|
return; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|