Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Mysql handle not in asynchronous mode

by sundialsvc4 (Abbot)
on Jul 16, 2011 at 11:34 UTC ( #914832=note: print w/ replies, xml ) Need Help??


in reply to Mysql handle not in asynchronous mode

Another possible strategy would be to wrap those low-level DBI calls in logic that specifically catches error #2000, and responds by sleeping for a short-but-random period of time and trying the request again a certain number of times before giving up.   This becomes a targeted response to a specific error condition, applied only when DBI informs you that the error in question just did occur.

sub doit { my $dbh = shift; # IF ASYNC ERROR OCCURS, RETRY THIS MANY TIMES for my $retry (1..10) { $dbh->execute(); # LEAVE NOW IF THE ERROR (IF ANY) IS OTHER THAN "ASYNC" return $dbh->err unless $dbh->err == 2000; # ASYNC ERROR ... TAKE A RANDOM SHORT NAP sleep(100*rand()); } # OH DEAR ... die "asynchronous I/O error"; }
Something like that ...


Comment on Re: Mysql handle not in asynchronous mode
Download Code
Re^2: Mysql handle not in asynchronous mode
by punkish (Priest) on Jul 16, 2011 at 16:34 UTC
    Thanks. I will implement your suggested workaround for now, but I would really like to understand why this problem is happening, and how I can avoid it in the first place.


    when small people start casting long shadows, it is time to go to bed

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://914832]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2015-07-04 02:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls