Question regarding Perl, DBI, and fork() - Mailing list pgsql-general

From Allen Landsidel
Subject Question regarding Perl, DBI, and fork()
Date
Msg-id 6.0.0.22.0.20031026145720.0249d258@pop.hotpop.com
Whole thread Raw
Responses Re: Question regarding Perl, DBI, and fork()  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
I have a job-processing backend written in perl, talking to a (of course)
postgres database.  The perl app has a master process that checks the
database periodically for jobs that need processed.  When there are
available jobs, it grabs some number of them (up a few hundred), and
fork()'s to create job processing processes, one per job, again up to a few
hundred.

I know the child processes inherit the db handle, as I learned the hard way
about InactiveDestroy ;) so my question is this:

Can the children (safely) use this handle to run database queries, or
should I just consider the handle garbage?  I didn't want to "just try and
see" because there's always the possibility it could work "by accident"
during the low-load testing, and fail at some other time.

Relevant versions of everything are:

FreeBSD 4.8 (Tracking RELENG_4, now 4.9-RC)
PostGreSQL 7.3.4
perl 5.003 (FreeBSD default)
perl DBI 1.37
perl DBD::Pg 1.22

I'm on the list, CC directly only if you're bored.  Thanks.

-Allen


pgsql-general by date:

Previous
From: Lynn.Tilby@asu.edu
Date:
Subject: Re: no records returned
Next
From: Alvaro Herrera
Date:
Subject: Re: incrementing and decrementing dates by day increments programmatically