Background:

I have a couple of programs which access different remote databases distributed in our wan. The programs are invoked in a cronish manner several times a day. The communication is done with tcp/ip over fixed 2Mb lines.

Current situation:

Lately there has been a lot of problems with the reliability of those links, related to HW-failure at the link provider and excavators cutting the backbone fiber, etc, etc.

Problem:

Until recently I didn't think this was a major problem with the application, because if the program failed with a timeout due to the broken link, then DB's would be resynced on the next time the programs starts with a functional link

However, here's where I spotted an, to me anyways, odd behaviour of possibly DBI and/or DBD::ODBC.

Consider this scenario

  1. The link is broken
  2. The program starts.
  3. A few seconds after the DBI->connect method was invoked the program dies with a msg saying that an timeout has occurred.
  4. Time passes ...
  5. The program starts again.
  6. .... but it never exits ....
  7. The link goes up again, but the program started at 5 is still in blocking wait or whatever.
  8. I kill the program manually.
  9. The program starts again and remember that the link is now up.
  10. .... but it never exits from connect.

The fix:

What I did was to use Net::Ping to test wheter the link was up before invoking the connect method of DBI. This does however not handle the case where the link goes down during a connection, and the previous scenario could very well occur again.

More info
Program fail on Win2000 and WinXP
AS perl v 635
DBI v 1.37
DBD::ODBC v 1.05

Also I'm using DSN's to connect.

my $dbh = DBI->connect("DBI:ODBC:$dsn") or die "Could not connect to $dsn >> $DBI::errstr\n";

I have tried to find something related through google and one of the mailing-list archives for DBI, but no avail.

Question:

As I'm totally stumped by this, I welcome any input to the problem.


In reply to Timeout problems with DBI by guha

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.