Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Now I'm at a loss, how did you successfully create a pool of DBI handles with multiple children? I have a pool set, but as soon as my first child ends, DBI tries to clean itself up and kills all my other DBI handles with "end-of-file on communication channel during global destruction" error.

My code (trimmed down):

my %pool; my %dbhs; $MAX = 5; $pm->run_on_start(\&_child_start); $pm->run_on_finish(\&_child_finish); my @dbhs = start_dbh(); %pool = map { $_ => 1 } @dbhs; foreach $i ( @is ) { ($next) = grep ( defined($pool{$_}), @dbhs ); $pid = $pm->start($next) and next; $sys->set_dbh($dbhs{$next}); sleep(rand(10)); $pm->finish; } sub start_dbh() { %dbhs = map { $_ => DBI::Connect(); } 0 .. $MAX; return keys %dbhs; } Sys::set_dbh() { my $this = shift; $this->{'_dbh-child'} = shift; } sub _child_start() { my ($pid, $ident) = @_; delete($pool{$ident}); print "**** STARTED: child with PID $pid"; } sub _child_finish(){ my ($pid, $exit, $ident) = @_; print "**** FINISHED: child with PID $pid exit cide $exit"; $pool{$ident} = 1; }

And as soon as the first child dies all my DBI handlers spew out: DBD::Oracle::db DESTROY failed: ORA-03113: end-of-file on communication channel (DBD Error: OCISessionEnd) during global destruction.

-- philip
We put the 'K' in kwality!

In reply to Re^2: Parallel::ForkManager using up Resources? by guice
in thread Parallel::ForkManager eating up Resources? by guice

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2022-12-04 07:29 GMT
Find Nodes?
    Voting Booth?

    No recent polls found