[cx-oracle-users] Safely replacing a SessionPool after database restart?
Brought to you by:
atuining
From: Forest W. [sf] <mo...@ti...> - 2006-01-25 00:14:28
|
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 is found, and rely on this safeguard to keep anything bad from happening when remaining old connections get returned to the new pool. Is there a better approach? |