Tuesday, November 1, 2011

What is Purge Policy ?

Purge Policy settings specifies how to purge connections when a stale connection or fatal connection error is detected.

Valid values are EntirePool and FailingConnectionOnly.

EntirePool: If you set the purge policy for this data source object to EntirePool, all connections in the pool are marked stale. Any connection not in use is immediately closed. A connection in use is closed and throws a StaleConnectionException during the next operation on that connection. Subsequent get Connection requests from the application result in new connections to the database opening. 

When using this purge policy, there is a slight possibility that some connections in the pool are closed unnecessarily when they are not stale. However, this is a rare occurrence. In most cases, a purge policy of EntirePool is the best choice.

FailingConnectionOnly: If you set the purge policy to FailingConnectionOnly, only the connection that caused the StaleConnectionException is closed. While this setting eliminates the possibility that valid connections are closed unnecessarily, it makes recovery from an application perspective more complicated. Because only the currently failing connection is closed, there is a good possibility that the next get Connection request from the application can return a connection from the pool that is also stale, resulting in more stale connection exceptions.

1 comment: