Can someone please advise on why I get errors opening the file in the code below. The errors start about half way through the 9th iteration of 25 threads, and are "Too many open files" errors. The error only happens when running in threads, and only when the DBI connect/disconnect are used. This shouldn't affect the open file count at all should it? I'm fairly new to Perl so not sure if I've done something weird. This is on Perl 5.8.8. on Solaris 10.
use threads (); use DBI; use DBD::Oracle; my $thrds=25; my $iter=11; my @threads; for (my $j=0; $j<$iter; $j++) { &start($j); } sub start { my $k=$_[0]; for (my $i=0; $i<$thrds; $i++) { $threads[$i] = threads->new(\&RunThread,$k, $i); } for (my $i=0; $i<$thrds; $i++) { $threads[$i]->join; } } sub RunThread { my $dbh = DBI->connect("dbi:Oracle:ora", "user","pass") or die "fa +iled connect"; my ($x, $y)=@_; open (my $fh2, ">/tmp/da-$x-$y") or die "failed in thread $! at it +er $x thread $y " ; close ($fh2); $dbh->disconnect or die "disconnect failed"; }

In reply to Too many open files error with DBD Oracle by JoeW

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.