Re: Sharing database handles across forked child processes
От | Greg Sabino Mullane |
---|---|
Тема | Re: Sharing database handles across forked child processes |
Дата | |
Msg-id | 537ea49b39c7ab32c546fea4b7426df4@biglumber.com обсуждение исходный текст |
Ответ на | Re: Sharing database handles across forked child processes (dan@sidhe.org) |
Ответы |
Re: Sharing database handles across forked child
processes
|
Список | pgsql-general |
-----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 > Yep, this is a fork without exec. And the child processes often aren't > even doing any database access -- the database connection's opened and > held, then a child is forked off, and the child 'helpfully' closes the > handle during the child's global destruction phase. > > Am I at any risk in the parent process? Yes. But there is an easy solution, asuming you are using DBI: $dbh->{InactiveDestroy} = 1; This tells DBI not to do anything special when inside of DESTROY. Set on the kids immediately after forking. > "the child processes often aren't even doing any database access" ^^^^^^^^^^^^ Often aren't? This should be "never", period, unless the parent contracts to stop doing database access after the fork. You can't have two processes sharing a handle. Note also that InactiveDestroy should not be your first choice. Far better to do the forking before the database connection whenever possible. If they both need access, you can also disconnect, fork, and have both reconnect afterwards. - -- Greg Sabino Mullane greg@turnstep.com End Point Corporation PGP Key: 0x14964AC8 200711131332 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 -----BEGIN PGP SIGNATURE----- iD8DBQFHOe7qvJuQZxSWSsgRA/BUAJ4tfyoZja93h3q6EtJ3lHiGRRODOACg/M2Y 5VlkKiSZNfstdgrD5Ru+Q/c= =OjGF -----END PGP SIGNATURE-----
В списке pgsql-general по дате отправления: