Can someone 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=10;
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:lnrmsd9.world", "rms_reader", "rms_reader") or die "failed connect";
my ($x, $y)=@_;
open (my $fh, ">/tmp/da") or die "failed $! at iter $x thread $y";
close ($fh);
$dbh->disconnect;
}