What I don't understand is what you are worried about?

Whether you are using Apache::DBI or David Wheelers DBIHandler (do I have that 
correct?) both will behave according to
the configuration of the database and web server.

Why not just let the servers decide whether to maintain or destroy a connection 
according to your configuration?
Set your timeouts in both Oracle and Apache and let them deal with it

On 11/13/2014 07:39 AM, Xinhuan Zheng wrote:

< If TTL were implemented, the module would have to disconnect from db 
connection after a pre-defined timeout so the
oracle server process could be shut down more gracefully. Would it be possible 
to implement that? Or is it too hard to implement?

No one cares about shutting down Oracle gracefully. I have not used "shutdown 
immediate", other than by mistake in probably 10 years.
I have never successfully used "shutdown normal"

Idle db connections cost almost nothing, establishing a connection is expensive.

Warning: I am better at Oracle than perl, and I am not very good with either :)

YMMV

Dave


- xinhuan

From: Paul Silevitch <p...@silevitch.com <mailto:p...@silevitch.com>>
Date: Wednesday, November 12, 2014 at 11:53 PM
To: Xinhuan Zheng <xzh...@christianbook.com <mailto:xzh...@christianbook.com>>, modperl 
<modperl@perl.apache.org <mailto:modperl@perl.apache.org>>
Subject: Re: Disconnect database connection after idle timeout

I don't fully understand your need here.  I'm going to give my best.

You could set an alarm in the cleanup handler that calls the disconnect after a 
specified amount of time.  If a new request comes in, you could cancel the 
alarm in a postreadrequest handler (or
something early in the cycle).  To cover the race condition where the 
disconnect happens right before the cancel, you could check to make sure the 
database connection is active right after the cancel
is called.

HTH,

Paul

On Wed, Nov 12, 2014 at 9:36 PM, Xinhuan Zheng <xzh...@christianbook.com 
<mailto:xzh...@christianbook.com>> wrote:

    Hello,

    I am having a database connection management question. Our apache+mod_perl 
application initiates a database connection request when it needs to then do 
data processing. Afterwards, if there is no
    more requests coming to this apache process, the database connection 
basically will be sitting there in idle state for quite a while until the OS 
TCP/IP idle timeout has reached. At that point the
    database would send a message into its alert log, telling that a connection 
timeout has occurred and the server process will be cleaned. I would like to 
figure out if mod_perl application can
    implement keep-alive timeout mechanism. The mod_perl would maintain the 
database connection after it finishes some processing until an idle timeout 
defined in the application has reached, for
    example, 5 minutes. Then the mod_perl would initiate a database 
disconnection request so the server process can be cleaned more gracefully. We 
are using Oracle 11g database. I knew in 11G oracle
    has implemented the connection pooling. I would think the oracle side 
connection pooling would be the server side maintaining the connection idle 
timeout. Would it be possible on the client side
    the mod_perl implement something like that? I just don’t know which side is 
more appropriate and how on the client side it can implement something like 
that.

    Thanks,
    - xinhuan




--
Dave Morgan
Senior Consultant, 1001111 Alberta Limited
dave.mor...@1001111.com
403 399 2442

Reply via email to