2011-12-09 82 views
0

下一個代碼與即時客戶10克正確的,但是使用Oracle客戶端11克時掛機,掛在pool.release(CONN),cx_Oracle + Oracle實例客戶11克掛斷


import time 
print '---------------------------------' 
import cx_Oracle 
print cx_Oracle.clientversion() 
time.sleep(1) 
pool = cx_Oracle.SessionPool('login', 'pass', "dbserver:1521/db", 1, 6, 2) 
pool.timeout = 60 
con11 = pool.acquire() 
con12 = pool.acquire() 
con13 = pool.acquire() 
con14 = pool.acquire() 
con15 = pool.acquire() 
pool.release(con11) 
pool.release(con12) 
pool.release(con13) 
pool.release(con14) 
pool.release(con15) 
for i in xrange(100000): 
    print '-=-' + str(i) + '-=-' 
    print str(pool.opened) + " " + str(pool.busy) 
    con1 = pool.acquire() 
    cursor = con1.cursor() 
    cursor.execute("SELECT * FROM DUAL") 
    count = cursor.fetchall()[0][0] 
    cursor.close() 
    print str(pool.opened) + " " + str(pool.busy) 
    con2 = pool.acquire() 
    cursor = con2.cursor() 
    cursor.execute("SELECT * FROM DUAL") 
    count = cursor.fetchall()[0][0] 
    cursor.close() 
    print str(pool.opened) + " " + str(pool.busy) 
    con3 = pool.acquire() 
    cursor = con3.cursor() 
    cursor.execute("SELECT * FROM DUAL") 
    count = cursor.fetchall()[0][0] 
    cursor.close() 
    print str(pool.opened) + " " + str(pool.busy) 
    t1 = time.time() 
    pool.release(con3) 
    t2 = time.time() 
    print t2 - t1 
    print str(pool.opened) + " " + str(pool.busy) 
    t1 = time.time() 
    pool.release(con2) 
    t2 = time.time() 
    print t2 - t1 
    t1 = time.time() 
    pool.release(con1) 
    t2 = time.time() 
    print t2 - t1 
    print str(pool.opened) + " " + str(pool.busy) 
print '---------------------------------' 

PS:我拿看看cx_Oracle源代碼,它的手在seesionpool.c上線

status = OCISessionRelease(connection->handle, 
      connection->environment->errorHandle, NULL, 0, mode);

任何想法如何解決它?

PPS:操作系統Windows XP和2008R2

回答

1

昨天我有同樣的症狀:在帶有會話池的多線程應用程序中,有時會釋放會話掛起長達2分鐘。

你可能會碰到以下Oracle錯誤之一:

錯誤10157313 - 過多的CPU使用率和OCISessionRelease表現不佳使用OCI會話池時(文件號10157313.8)

錯誤10157313:OCI SESSION POOLING會增加CPU使用量,並且在使用時需要很長時間才能釋放11.2

有關詳細信息,請參閱Oracle Metalink。

將Oracle客戶端軟件更新到11.2.0.3或更高版本(例如InstantClient 11.2.0.3)似乎有所幫助。