perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xinhuan Zheng <>
Subject Re: Apache::DBI "connection lost contact" error
Date Thu, 06 Jun 2013 17:22:38 GMT
Hi Perrin,

I think I have one more request.

The database handle that is created in needs to be really disconnected (not overloaded
disconnect) so that won't leave an idle server process running on the database side. Once
it's really disconnected, the server process can be cleaned up on the server side.

For child processes, I guess they don't need to really disconnect until the time the child

- xinhuan

From: Perrin Harkins <<>>
Date: Wednesday, June 5, 2013 12:08 PM
To: Xinhuan Zheng <<>>
Cc: Jim Schueler <<>>, "<>"
Subject: Re: Apache::DBI "connection lost contact" error

On Tue, Jun 4, 2013 at 2:32 PM, Xinhuan Zheng <<>>
> I have seen in other web servers when apachectl starts, there is no "connect lost contact"
error but it did happen when apachectl stops.

If your server does not receive constant requests, you may see this error on shutdown because
cached database handles are being destroyed but the connection to the database has already
timed out.

> If child process uses ping the inherited database handle and it is ping-able, then the
child process may use it. That'll be a problem.

The debugging log you showed us makes me think that won't happen.  It looks like the handle
fails immediately when used after a fork.

> When child process exits, it calls rollback if AutoCommit is off, but when another new
child process is just born and uses its connection to send
> database updates, will that rollback interfere with new child process attempt to update

If the same connection was being used in multiple processes, many things could go wrong, including
that.  However, Since the connections die immediately when you use them after a fork, this
won't happen.

> Is the rollback necessary?

It's very necessary.  Otherwise, if your code throws an uncaught exception in the middle of
some database work, the next request would reuse the same handle with uncommitted changes
left on it.  In my opinion, this is the most important thing about Apache::DBI.

I understand you're worried about it.  I should be able to send you a patch to try within
a few days, so you can wait for that if you want.  Or you can try to fix it yourself.  My
plan is to replace that line of code I showed with some code that checks current_callback()
to make sure we're not in a startup phase.

- Perrin

View raw message