On 03/21/2013 11:51 AM, David Stanek wrote:
> We are seeing a strange issue where DRCP connections are not being returned to the pool even after the connection is closed. My sample code (http://pastebin.com/UB5cPtsZ) shows a really simple example where I create more processes than I have connections
> in the pool. I expected the connection to be available for reuse by the time the child process sleeps. Then I would expect to see a stream of output and the processes would all exit in about 10 seconds.
> What I'm actually seeing is every process making a connection, but the queries for processes above the number of connections in the pool block until some of the processes die. So every 10 seconds or so a few more queries run.
> Does the process really need to die for the connection to be released?
Try an explicit session pool:
print 'starting do_connection ' + str(os.getpid())
mypool = cx_Oracle.SessionPool(user=user,password=pw,dsn=dsn,min=1,max=2,increment=1)
con = cx_Oracle.connect(user=user, password=pw, dsn=dsn, pool = mypool, cclass="blah", purity=cx_Oracle.ATTR_PURITY_SELF)
cur = con.cursor()
print 'Querying ' + str(os.getpid())
cur.execute("select to_char(systimestamp) from dual")
print 'Sleeping ' + str(os.getpid())
print 'finishing do_connection ' + str(os.getpid())
user = 'hr'
pw = 'welcome'
dsn = 'localhost/orcl:pooled'
for x in range(100):
pid = os.fork()
if not pid:
Mod_python etc users can create the session pool outside the handler,
otherwise re-authentication occurs for every connect and
NUM_AUTHENTICATIONS will equal NUM_REQUESTS in V$CPOOL_CC_STATS.
Newly updated, free PHP & Oracle book: