Re: [cx-oracle-users] Safely replacing a SessionPool after database restart?
Brought to you by:
atuining
From: Anthony T. <ant...@gm...> - 2006-01-25 23:18:46
|
The technique that we have been using is to simply replace the pool after a database restart. Any existing connections acquired from the pool will fail on the next attempt to do something, including the attempt to release back to the pool. Note that when a connection is garbage collected it is automatically returned to the correct pool. You don't need to explicitly call pool.release() unless you want it to happen before the connection is garbage collected. The safeguard of ensuring that you are not trying to release the connection back to the wrong pool should work -- but even if it does not, Oracle will give you an error so I think you can rest easy on that one. Hope that helps. On 1/24/06, Forest Wilkinson [sf] <mo...@ti...> wrote: > I'm trying to get my code to handle a database restart automatically, > which turns out to be tricky when using a SessionPool. > > My first approach was to use SessionPool.drop() instead of release() when > a dead connection was detected, but it turns out that drop() fails after = a > database restart. > > My second approach was to replace the SessionPool entirely when a dead > connection was detected. In order to keep any remaining old connections > from being released to the new pool, I tried waiting for SessionPool.busy > to reach 0 before doing the replacement. Unfortunately, in practice, it > never reached 0. This was probably because release() fails with my dead > connection, so it can never be returned to the pool. In other words, a > kind of deadlock. > > Out of curiosity, I tried deliberately releasing a connection to a > SessionPool it didn't come from, to see how cx_Oracle would respond. It > raised a cx.ProgrammingError. Is this safeguard guaranteed to work? If > so, I suppose I can replace my SessionPool as soon as a dead connection i= s > found, and rely on this safeguard to keep anything bad from happening whe= n > remaining old connections get returned to the new pool. > > Is there a better approach? > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D103432&bid=3D230486&dat= =3D121642 > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |