Hi,

I'm trying to make an existing DBI::Proxy-using GUI-app. more robust by trying to make it recover from a network failure. Right now I'm puzzled by a 'broken pipe' message I get on the client-side when I break the network connection between client and server. After this message the app. stops, I can't seem to catch this with an 'eval'. The code is something like:

my $retval = eval { $sth->execute(@values); }; unless ($retval) { _db_recover(); } ... sub _db_recover { eval { $dbh->disconnect(); }; warn("reconnecting to database in 20 seconds\n"); sleep 20; eval { $dbh->connect(@somevalues); }; }
Note this is still in development, I don't want to reconnect everytime the execute fails.

I've also tried to change the signal-hash locally to 'IGNORE' the $SIG{PIPE} and $SIG{DIE} signals (in fact I've even tried to set the values of the whole %SIG to 'IGNORE') but the app. still stops executing.

While debugging I found DBD::Proxy holds an IO::Socket that gets disconnected when I disconnect the network connection (duh), this most probably causes the 'broken pipe' message, but I can't bend my mind around how to access this Socket or how to recreate it after a network failure.

Any idea's on how I can keep my app. (at least) running in these situations?

Update: fixed $dbh->execute to $sth->execute


In reply to script dies with 'broken pipe'-message, even in eval by eXile

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.