Hmm.

I tried that before one of my attempts had that in the same hash as raiseerror.., and now that I think on what you said -- it does seem to work.

After a bit of a re-write, I realise that my issue seems to be if the DB server is gone, and a query is attempted. Something that can happen between even a DBI PING and QUERY.

If that happens, it just hangs in a 'wait' state forever.

EG:

- I'm connected
- I run a query or two
- the MySQL server vanishes
- I do a prepare and an execute of a query
- I get an error, and raiseerror is on...
- I get 'execute failed' and it simply hangs forever

Just in case, I've also tried with 'or die' at the end of the execute statement. It still hangs.

I have a debugging like .. print "BAH"; right after the execute statement, and it is never reached.

I've tried wrapping it in an eval, without an eval around it, using connect_cached and connect, using raiseerror or not, the list goes on.

Should a query just hang, if it can't reach the server?! I'm guessing 'connect timeout' is only for connect.

Yet, I'm getting an error stating lost connection, so why aren't I getting a raisederror, or the die kicking in?!

HELP! :P

Thanks btw for the prior, at least I have a much better idea of what the issue is...

AH.

Perl version.. 5.22

So... just to add to this in an edit....

I'm trying alarm right now. It works, and I'm monkeying with it.

But, all over the place I see posts about 'don't do alarm, do this', then other places 'don't do THAT, do this instead' then 'perl v$x will segfault with this and....

I guess my question is.. I can't find a complete "This is how to do completely foolproof MySQL handling under perl, for all versions, catching all errors, etc..." anywhere.

Maybe I'm Googling the wrong thing. But, any suggestions?

Is alarm OK 100% of the time, in every single case?


In reply to Re^2: mysql_connect_timeout laughs at me by bbarnett
in thread mysql_connect_timeout laughs at me by bbarnett

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.