| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
DBIx::TryAgain - If at first you don't succeed, try DBIx::TryAgain. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $dbh = DBIx::TryAgain->connect(...) or die $DBI::errstr; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
OR |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $dbh = DBI->connect(... dbi params.. { RootClass => "DBIx::TryAgain" } ) or die $DBI::errstr; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$dbh->try_again_algorithm('fibonacci'); |
|
14
|
|
|
|
|
|
|
$dbh->try_again_max_retries(5); |
|
15
|
|
|
|
|
|
|
$dbh->try_again_on_messages([ qr/database is locked/i ]); |
|
16
|
|
|
|
|
|
|
$dbh->try_again_on_prepare(1); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This is a subclass of DBI which simply tries to execute a query |
|
21
|
|
|
|
|
|
|
again whenever the error string matches a given set of patterns. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
By default the only pattern is qr[database is locked], which is |
|
24
|
|
|
|
|
|
|
what is returned by SQLite when the database is locked. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
There is a delay between retries. Setting try_again_algorithm |
|
27
|
|
|
|
|
|
|
to 'constant', 'linear', 'fibonacci', or 'exponential' causes |
|
28
|
|
|
|
|
|
|
the corresponding algorithm to be used. The first five |
|
29
|
|
|
|
|
|
|
values for these algorithsm are : |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
constant : 1,1,1,1,1 |
|
32
|
|
|
|
|
|
|
linear : 1,2,3,4,5 |
|
33
|
|
|
|
|
|
|
fibonacci : 1,1,2,3,5 |
|
34
|
|
|
|
|
|
|
exponential : 1,2,4,8,16 |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Modify the PrintError attribute and DBI_TRACE environment (as with |
|
37
|
|
|
|
|
|
|
DBI) to change the level of verbosity of this module. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
In addition to retrying an execute(), DBIx::TryAgain and also |
|
40
|
|
|
|
|
|
|
retry a prepare statement, by calling $dbh->try_again_on_prepare(1); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 AUTHOR |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Brian Duggan, C<< >> |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
L |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 TODO |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Support error codes as well as messages. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
package DBIx::TryAgain; |
|
57
|
|
|
|
|
|
|
|
|
58
|
3
|
|
|
3
|
|
101379
|
use strict; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
260
|
|
|
59
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
149
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
62
|
|
|
|
|
|
|
|
|
63
|
3
|
|
|
3
|
|
16782
|
use DBI ( ); |
|
|
3
|
|
|
|
|
80489
|
|
|
|
3
|
|
|
|
|
123
|
|
|
64
|
3
|
|
|
3
|
|
2419
|
use DBIx::TryAgain::st; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
221
|
|
|
65
|
3
|
|
|
3
|
|
2000
|
use DBIx::TryAgain::db; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
143
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
our @ISA = 'DBI'; |
|
68
|
|
|
|
|
|
|
|