blib/lib/DBIx/Connector/Retry.pm

filter: Statementstmt 93.1% 95 / 102 Branchbran 79.4% 27 / 34 Conditioncond 86.3% 19 / 22 MC/DCmcdc 70.0% 7 / 10 Subroutinesub 84.2% 16 / 19 Podpod 66.6% 2 / 3 totaltotal 87.3% 166 / 190 CC 26 SCAR 20.1
CC
26
Cov
89%
__ANON__
13.2
_retry_loop
11.3
__ANON__
3.0
CRAP 7.4
↑ Summary
1 package DBIx::Connector::Retry;
2  
3 3 our $AUTHORITY = 'cpan:GSG';
4 # ABSTRACT: DBIx::Connector with block retry support
5 3 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 our $VERSION = 'v0.900.1'; # VERSION
7  
8 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 extends 'DBIx::Connector', 'Moo::Object';
14  
15 3 ▶use Scalar::Util qw( weaken );
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use Types::Standard qw( Str Bool HashRef CodeRef Dict Tuple Optional Maybe );
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 ▶use Types::Common::Numeric qw( PositiveInt );
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 3 ▶use namespace::clean; # don't export the above
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 #pod =encoding utf8
22 #pod
23 #pod =head1 SYNOPSIS
24 #pod
25 #pod my $conn = DBIx::Connector::Retry->new(
26 #pod connect_info => [ 'dbi:Driver:database=foobar', $user, $pass, \%args ],
27 #pod retry_debug => 1,
28 #pod max_attempts => 5,
29 #pod );
30 #pod
31 #pod # Keep retrying/reconnecting on errors
32 #pod my ($count) = $conn->run(ping => sub {
33 #pod $_->do('UPDATE foobar SET updated = 1 WHERE active = ?', undef, 'on');
34 #pod $_->selectrow_array('SELECT COUNT(*) FROM foobar WHERE updated = 1');
35 #pod });
36 #pod
37 #pod # Add a simple retry_handler for a manual timeout
38 #pod my $start_time = time;
39 #pod $conn->retry_handler(sub { time <= $start_time + 60 });
40 #pod
41 #pod my ($count) = $conn->txn(fixup => sub {
42 #pod $_->selectrow_array('SELECT COUNT(*) FROM barbaz');
43 #pod });
44 #pod $conn->clear_retry_handler;
45 #pod
46 #pod # Plus everything else in DBIx::Connector
47 #pod
48 #pod =head1 DESCRIPTION
49 #pod
50 #pod DBIx::Connector::Retry is a Moo-based subclass of L<DBIx::Connector> that will retry on
51 #pod failures. Most of the interface was modeled after L<DBIx::Class::Storage::BlockRunner>
52 #pod and adapted for use in DBIx::Connector.
53 #pod
54 #pod =head1 ATTRIBUTES
55 #pod
56 #pod =head2 connect_info
57 #pod
58 #pod An arrayref that contains all of the connection details normally found in the L<DBI> or
59 #pod L<DBIx::Connector> call. This data can be changed, but won't take effect until the next
60 #pod C<$dbh> re-connection cycle.
61 #pod
62 #pod Obviously, this is required.
63 #pod
64 #pod =cut
65  
66 3 has connect_info => (
67 is => 'rw',
68 # Yes, DBI->connect() is still technically-valid syntax
69 isa => Tuple[ Maybe[Str], Maybe[Str], Maybe[Str], Optional[HashRef] ],
70 required => 1,
71 );
72  
73 #pod =head2 mode
74 #pod
75 #pod This is just like L<DBIx::Connector/mode> except that it can be set from within the
76 #pod constructor.
77 #pod
78 #pod Unlike DBIx::Connector, the default is C<ping>, not C<no_ping>.
79 #pod
80 #pod =cut
81  
82 3 has _mode => (
83 is => 'bare', # use DBIx::Connector's accessor
84 isa => Str,
85 init_arg => 'mode',
86 required => 0,
87 default => 'ping',
88 );
89  
90 #pod =head2 disconnect_on_destroy
91 #pod
92 #pod This is just like L<DBIx::Connector/disconnect_on_destroy> except that it can be set
93 #pod from within the constructor.
94 #pod
95 #pod Default is on.
96 #pod
97 #pod =cut
98  
99 3 has _dond => (
100 is => 'bare', # use DBIx::Connector's accessor
101 isa => Bool,
102 init_arg => 'disconnect_on_destroy',
103 required => 0,
104 default => 1,
105 );
106  
107 #pod =head2 max_attempts
108 #pod
109 #pod The maximum amount of block running attempts before the Connector gives up and dies.
110 #pod
111 #pod Default is 10.
112 #pod
113 #pod =cut
114  
115 3 has max_attempts => (
116 is => 'rw',
117 isa => PositiveInt,
118 required => 0,
119 default => 10,
120 );
121  
122 #pod =head2 retry_debug
123 #pod
124 #pod If enabled, any retries will output a debug warning with the error message and number
125 #pod of retries.
126 #pod
127 #pod =cut
128  
129 3 has retry_debug => (
130 is => 'rw',
131 isa => Bool,
132 required => 0,
133 default => 0,
134 lazy => 1,
135 );
136  
137 #pod =head2 retry_handler
138 #pod
139 #pod An optional handler that will be checked on each retry. It will be passed the Connector
140 #pod object as its only input. If the handler returns a true value, retries will continue.
141 #pod A false value will cause the retry loop to immediately rethrow the exception. You can
142 #pod also throw your own, if you prefer.
143 #pod
144 #pod This check is independent of checks for L</max_attempts>.
145 #pod
146 #pod The last exception can be inspected as part of the check by looking at L</last_exception>.
147 #pod This is recommended to make sure the failure is actually what you expect it to be.
148 #pod For example:
149 #pod
150 #pod $conn->retry_handler(sub {
151 #pod my $c = shift;
152 #pod my $err = $c->last_exception;
153 #pod $err = $err->error if blessed $err && $err->isa('DBIx::Connector::RollbackError');
154 #pod
155 #pod $err =~ /deadlock|timeout/i; # only retry on deadlocks or timeouts
156 #pod });
157 #pod
158 #pod Default is an always-true coderef.
159 #pod
160 #pod This attribute has the following handles:
161 #pod
162 #pod =head3 clear_retry_handler
163 #pod
164 #pod Sets it back to the always-true default.
165 #pod
166 #pod =cut
167  
168 has retry_handler => (
169 is => 'rw',
170 isa => CodeRef,
171 required => 1,
172 9 ▶ default => sub { sub { 1 } },
Subroutine __ANON__: called CC=1 SCAR=1.2
173 3 );
174  
175 0 ▶sub clear_retry_handler { shift->retry_handler(sub { 1 }) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine clear_retry_handler: not called CC=1 SCAR=6.9
Pod documented
176  
177 #pod =head2 failed_attempt_count
178 #pod
179 #pod The number of failed attempts so far. This can be used in the L</retry_handler> or
180 #pod checked afterwards. It will be reset on each block run.
181 #pod
182 #pod Not available for initialization.
183 #pod
184 #pod =cut
185  
186 has failed_attempt_count => (
187 is => 'ro',
188 init_arg => undef,
189 writer => '_set_failed_attempt_count',
190 default => 0,
191 lazy => 1,
192 trigger => sub {
193 59 ▶ my ($self, $val) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.1
194 59 ▶ die sprintf (
Branch: 1 branch
BranchTrueFalseTotal
if $self->max_attempts <= ($val || 0) 0 59 59
Condition100%2/2
$val || 0
l!l
2435
MC/DC100%1/1
$val || 0
$val
Truth table100%2/2
A
A= $val
Aresult
11
00
195 'Reached max_attempts amount of %d, latest exception: %s',
196 $self->max_attempts, $self->last_exception
197 ) if $self->max_attempts <= ( $val || 0 );
198 },
199 3 );
200  
201 #pod =head2 exception_stack
202 #pod
203 #pod The stack of exceptions received so far, as an arrayref. This can be used in the
204 #pod L</retry_handler> or checked afterwards. It will be reset on each block run.
205 #pod
206 #pod Not available for initialization.
207 #pod
208 #pod This attribute has the following handles:
209 #pod
210 #pod =head3 last_exception
211 #pod
212 #pod The last exception on the stack.
213 #pod
214 #pod =cut
215  
216 has exception_stack => (
217 is => 'ro',
218 init_arg => undef,
219 clearer => '_reset_exception_stack',
220 21 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
221 3 lazy => 1,
222 );
223  
224 0 ▶sub last_exception { shift->exception_stack->[-1] }
Subroutine last_exception: not called CC=1 SCAR=6.9
Pod documented
225  
226 #pod =head1 CONSTRUCTORS
227 #pod
228 #pod =head2 new
229 #pod
230 #pod my $conn = DBIx::Connector::Retry->new(
231 #pod connect_info => [ 'dbi:Driver:database=foobar', $user, $pass, \%args ],
232 #pod max_attempts => 5,
233 #pod # ...etc...
234 #pod );
235 #pod
236 #pod # Old-DBI syntax
237 #pod my $conn = DBIx::Connector::Retry->new(
238 #pod 'dbi:Driver:database=foobar', $user, $pass, \%dbi_args,
239 #pod max_attempts => 5,
240 #pod # ...etc...
241 #pod );
242 #pod
243 #pod As this is a L<Moo> class, it uses the standard Moo constructor. The L</connect_info>
244 #pod should be specified as its own key. The L<DBI>/L<DBIx::Connector> syntax is available,
245 #pod but only as a nicety for compatibility.
246 #pod
247 #pod =cut
248  
249 around BUILDARGS => sub {
250 14 ▶ my ($orig, $class, @args) = @_;
Subroutine __ANON__: called CC=13 SCAR=25.8
251  
252 # Old-style DBI/DBIx::Connector parameters. Try to fix it up.
253 14 ▶ if (@args && $args[0] && !ref $args[0] && $args[0] =~ /^dbi:/) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and $args[0] and not ref $args[0] and $args[0] =~ /^dbi:/) 6 8 14
Condition88%8/9
@args and $args[0] and not ref $args[0] and $args[0] =~ /^dbi:/
!ll&&!rl&&r
266
@args and $args[0] and not ref $args[0]
!ll&&!rl&&r
1112
@args and $args[0]
!ll&&!rl&&r
1013
MC/DC75%3/4
@args and $args[0] and not ref $args[0] and $args[0] =~ /^dbi:/
@args $args[0] not ref $args[0] $args[0] =~ /^dbi:/
Truth table80%4/5
A and B and not(C) and D
A= @argsB= $args[0]C= not ref $args[0]D= $args[0] =~ /^dbi:/
ABCDresult
0XXX0
10XX0
110X0
11100
11111
254 6 my @connect_info = splice(@args, 0, 3); # DBI DSN, UN, PW
255 6 ▶ push @connect_info, shift @args if $args[0] && (ref $args[0]||'') eq 'HASH'; # DBI \%attr, if it exists
Branch: 1 branch
BranchTrueFalseTotal
if $args[0] and (ref $args[0] || "") eq "HASH" 4 2 6
Condition80%4/5
$args[0] and (ref $args[0] || "") eq "HASH"
!ll&&!rl&&r
024
ref $args[0] || ''
l!l
51
MC/DC50%1/2
$args[0] and (ref $args[0] || "") eq "HASH"
$args[0] ref $args[0]
Truth table66%2/3
A and B
A= $args[0]B= ref $args[0]
ABresult
0X0
100
111
256  
257 6 ▶ if ( @args && $args[0] && (my $ref = ref $args[0]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and $args[0] and my $ref = ref $args[0]) { } 3 3 6
Condition83%5/6
@args and $args[0] and my $ref = ref $args[0]
!ll&&!rl&&r
123
@args and $args[0]
!ll&&!rl&&r
105
MC/DC66%2/3
@args and $args[0] and my $ref = ref $args[0]
@args $args[0] my $ref = ref $args[0]
Truth table75%3/4
A and B and C
A= @argsB= $args[0]C= my $ref = ref $args[0]
ABCresult
0XX0
10X0
1100
1111
258 3 ▶ if ($ref eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if ($ref eq 'ARRAY') { } 2 1 3
elsif ($ref eq 'HASH') { } 1 0 1
259 2 push @{$args[0]}, ( connect_info => \@connect_info );
260 2 @args = @{$args[0]}; # Moo::Object::BUILDARGS doesn't actually support lone ARRAYREFs
261 }
262 elsif ($ref eq 'HASH') {
263 1 $args[0]{connect_info} = \@connect_info;
264 }
265 else {
266 # Mimicing Moo::Object::BUILDARGS here
267 0 Carp::croak(join ' ',
268 "The new() method for $class cannot parse the strange argument list.",
269 "Please switch to a standard Moo constructor, instead of the DBI syntax.",
270 );
271 }
272 }
273 else {
274 # either the key within a list or we're out of arguments
275 3 push @args, ( connect_info => \@connect_info );
276 }
277 }
278  
279 14 return $class->$orig(@args);
280 3 };
281  
282 sub BUILD {
283 12 ▶ my ($self, $args) = @_;
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
284  
285 12 my @connect_args = @{ $self->connect_info };
286  
287 # Add in the keys that DBIx::Connector expects. For the purposes of future
288 # expandability of DBIx::Connector, we do this by getting a new base Connector
289 # object, and inject those properties into our own object.
290  
291 12 my $base_obj = DBIx::Connector->new(@connect_args);
292 12 %$self = (
293 %$base_obj,
294 %$self, # $self's existing attributes take priority
295 );
296  
297 # DBIx::Connector stores connection details in a coderef (for some reason). Instead
298 # of just dumping the same arguments as another copy, we'll tie it directly to the
299 # attr. If connect_info ever changes, it will grab the latest version.
300 12 ▶ $self->{_args} = sub { @{ $self->connect_info } };
Subroutine __ANON__: called CC=1 SCAR=0.0
301 12 weaken $self; # circular closure ref
302 }
303  
304 #pod =head1 MODIFIED METHODS
305 #pod
306 #pod =head2 run / txn
307 #pod
308 #pod my @result = $conn->run($mode => $coderef);
309 #pod my $result = $conn->run($mode => $coderef);
310 #pod $conn->run($mode => $coderef);
311 #pod
312 #pod my @result = $conn->txn($mode => $coderef);
313 #pod my $result = $conn->txn($mode => $coderef);
314 #pod $conn->txn($mode => $coderef);
315 #pod
316 #pod Both L<run|DBIx::Connector/run> and L<txn|DBIx::Connector/txn> are modified to run inside
317 #pod a retry loop. If the original Connector action dies, the exception is caught, and if
318 #pod L</retry_handler> and L</max_attempts> allows it, the action is retried. The database
319 #pod handle may be reset by the Connector action, according to its connection mode.
320 #pod
321 #pod See L</CAVEATS> for important behaviors/limitations.
322 #pod
323 #pod =cut
324  
325 3 foreach my $method (qw< run txn >) {
326 around $method => sub {
327 35 ▶ my $orig = shift;
Subroutine __ANON__: called CC=2 SCAR=7.0
328 35 my $self = shift;
329 35 ▶ my $mode = ref $_[0] eq 'CODE' ? $self->{_mode} : shift;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'CODE' ? : 0 35 35
330 35 my $cref = shift;
331  
332 35 my $wantarray = wantarray;
333  
334 35 return $self->_retry_loop($orig, $method, $mode, $cref, $wantarray);
335 6 };
336 }
337  
338 sub _retry_loop {
339 35 ▶ my ($self, $orig, $method, $mode, $cref, $wantarray) = @_;
Subroutine _retry_loop: called CC=11 SCAR=24.2
340  
341 35 $self->_reset_exception_stack;
342 35 $self->_set_failed_attempt_count(0);
343  
344 # If we already started in a transaction, that implies nesting, so don't
345 # retry the query. We can't guarantee that the statements before the block
346 # run will be committed, and are assuming that the connection will break.
347 #
348 # We cannot rely on checking the database connection via ping, because some
349 # DBDs (like mysql) will try to reconnect to the DB if the first ping check
350 # fails, and a reconnection auto-rollbacks all transactions, locks, etc.
351 35 ▶ if ($self->in_txn) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->in_txn) 25 10 35
352 25 ▶ unless (defined $wantarray) { return $self->$orig($mode, $cref) }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $wantarray) { } 25 0 25
if (do { $wantarray }) { } 25 0 25
353 25 elsif ($wantarray) { return ($self->$orig($mode, $cref)) }
354 0 else { return scalar $self->$orig($mode, $cref) }
355 }
356  
357 # Mode is localized within $orig, but we should localize it again ourselves, in case
358 # it's changed on-the-fly.
359 10 local $self->{_mode} = $mode;
360  
361 10 my $run_err;
362 my @res;
363  
364 10 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$run_err and do { do { TRY: { local $@; eval { do { if (defined $wantarray) { if (do { $wantarray }) { @res = $self->$orig($mode, $cref); } else { $res[0] = $self->$orig($mode, $cref); } } else { $self->$orig($mode, $cref); } } }; $run_err = $@; } ; if ($run_err) { push @{$self->exception_stack;}, $run_err; $self->_set_failed_attempt_count($self->failed_attempt_count + 1); die $run_err unless $self->retry_handler->($self); warn sprintf("Retrying %s coderef (attempt %d) after caught exception: %s", $method, $self->failed_attempt_count + 1, $run_err) if $self->retry_debug; } } } 24 10 34
365 TRY: {
366 34 local $@;
367 34 eval {
368 34 ▶ unless (defined $wantarray) { $self->$orig($mode, $cref) }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $wantarray) { } 2 32 34
if (do { $wantarray }) { } 1 1 2
369 1 elsif ($wantarray) { @res = $self->$orig($mode, $cref) }
370 1 else { $res[0] = $self->$orig($mode, $cref) }
371 };
372 34 $run_err = $@;
373 }
374  
375 34 ▶ if ($run_err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($run_err) 24 10 34
376 24 push @{ $self->exception_stack }, $run_err;
377  
378 # This will throw if max_attempts is reached
379 24 $self->_set_failed_attempt_count($self->failed_attempt_count + 1);
380  
381 # If the retry handler says no, then die
382 24 ▶ die $run_err unless $self->retry_handler->($self);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->retry_handler->($self) 0 24 24
383  
384 # Debug line
385 24 ▶ warn sprintf(
Branch: 1 branch
BranchTrueFalseTotal
if $self->retry_debug 0 24 24
386 'Retrying %s coderef (attempt %d) after caught exception: %s',
387 $method,
388 $self->failed_attempt_count + 1,
389 $run_err,
390 ) if $self->retry_debug;
391 }
392 } while ($run_err);
393  
394 10 ▶ return $wantarray ? @res : $res[0];
Branch: 1 branch
BranchTrueFalseTotal
$wantarray ? : 1 9 10
395 }
396  
397 #pod =head1 CAVEATS
398 #pod
399 #pod =head2 $dbh settings
400 #pod
401 #pod Like L<DBIx::Connector>, it's important that the L</connect_info> properties have sane
402 #pod connection settings.
403 #pod
404 #pod L<AutoCommit|DBI/AutoCommit> should be turned on. Otherwise, the connection is
405 #pod considered to be already in a transaction, and no retries will be attempted. Instead,
406 #pod use transactions via L<txn|DBIx::Connector/txn>.
407 #pod
408 #pod L<RaiseError|DBI/RaiseError> should also be turned on, since exceptions are captured,
409 #pod and both Retry and Connector use them to determine if any of the C<$dbh> calls failed.
410 #pod
411 #pod =head2 Savepoints and nested transactions
412 #pod
413 #pod L<The svp method|DBIx::Connector/svp> is NOT modified to work inside of a retry loop,
414 #pod because retries are generally not possible for savepoints, and a disconnected connection
415 #pod will rollback any uncommited statements in most RDBMS. The same goes for any C<run>/C<txn>
416 #pod calls attempted inside of a transaction.
417 #pod
418 #pod Consider the following:
419 #pod
420 #pod # If this dies, sub will retry
421 #pod $conn->txn(ping => sub {
422 #pod shift->do('UPDATE foobar SET updated = 1 WHERE active = ?', undef, 'on');
423 #pod
424 #pod # If this dies, it will not retry
425 #pod $conn->svp(sub {
426 #pod my $c = shift;
427 #pod $c->do('INSERT foobar (name, updated, active) VALUES (?, ?)', undef, 'barbaz', 0, 'off');
428 #pod });
429 #pod });
430 #pod
431 #pod If the savepoint actually tried to retry, the C<UPDATE> statement would get rolled back by
432 #pod virtue of database disconnection. However, the savepoint code would continue, possibly
433 #pod even succeeding. You would never know that the C<UPDATE> statement was rolled back.
434 #pod
435 #pod However, without savepoint retry support, as it is currently designed, the statements
436 #pod will work as expected. If the savepoint code dies, and if C<$conn> is set up for
437 #pod retries, the transaction code is restarted, after a rollback or reconnection. Thus, the
438 #pod C<UPDATE> and C<INSERT> statements are both ran properly if they now succeed.
439 #pod
440 #pod Obviously, this will not work if transactions are manually started outside of the main
441 #pod Connector interface:
442 #pod
443 #pod # Don't do this! The whole transaction isn't compartmentalized properly!
444 #pod $conn->run(ping => sub {
445 #pod $_->begin_work; # don't ever call this!
446 #pod $_->do('UPDATE foobar SET updated = 1 WHERE active = ?', undef, 'on');
447 #pod });
448 #pod
449 #pod # If this dies, the whole app will probably crash
450 #pod $conn->svp(sub {
451 #pod my $c = shift;
452 #pod $c->do('INSERT foobar (name, updated, active) VALUES (?, ?)', undef, 'barbaz', 0, 'off');
453 #pod });
454 #pod
455 #pod # Don't do this!
456 #pod $conn->run(ping => sub {
457 #pod $_->commit; # no, let Connector handle this process!
458 #pod });
459 #pod
460 #pod =head2 Fixup mode
461 #pod
462 #pod Because of the nature of L<fixup mode|DBIx::Connector/Connection Modes>, the block may be
463 #pod executed twice as often. Functionally, the code looks like this:
464 #pod
465 #pod # Very simplified example
466 #pod sub fixup_run {
467 #pod my ($self, $code) = @_;
468 #pod
469 #pod my (@ret, $run_err);
470 #pod do {
471 #pod eval {
472 #pod @ret = eval { $code->($dbh) };
473 #pod my $err = $@;
474 #pod
475 #pod if ($err) {
476 #pod die $err if $self->connected;
477 #pod # Not connected. Try again.
478 #pod return $code->($dbh);
479 #pod }
480 #pod };
481 #pod $run_err = $@;
482 #pod
483 #pod if ($run_err) {
484 #pod # Push exception_stack, set/check attempts, check retry_handler
485 #pod }
486 #pod } while ($run_err);
487 #pod return @ret;
488 #pod }
489 #pod
490 #pod If the first eval dies because of a connection failure, the code is ran twice before the
491 #pod retry loop finds it. This is only considered to be one attempt. If it dies because of
492 #pod some other fault, it's only ran once and continues the retry loop.
493 #pod
494 #pod If this is behavior is undesirable, this can be worked around by using the L</retry_handler>
495 #pod to change the L<mode|DBIx::Connector/mode> after the first attempt:
496 #pod
497 #pod $conn->retry_handler(sub {
498 #pod my $c = shift;
499 #pod $c->mode('ping') if $c->mode eq 'fixup';
500 #pod 1;
501 #pod });
502 #pod
503 #pod Mode is localized outside of the retry loop, so even C<< $conn->run(fixup => $code) >>
504 #pod calls work, and the default mode will return to normal after the block run.
505 #pod
506 #pod =head1 SEE ALSO
507 #pod
508 #pod L<DBIx::Connector>, L<DBIx::Class>
509 #pod
510 #pod =cut
511  
512 3 1;
513  
514 __END__
↑ Summary