cx_Oracle + oracle实例客户端11g挂掉

发布于 2024-12-20 11:53:40 字数 1888 浏览 2 评论 0原文

下一个代码在即时客户端 10g 上工作正常,但在使用 Oracle 即时客户端 11g 时挂起,挂在 pool.release(conN) 上,


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

next code works correct with instant client 10g, but hang up when using oracle instant client 11g, hangs on pool.release(conN),


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: I take look into cx_Oracle source code, it's hands in seesionpool.c on line

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

Any ideas how to solve it?

PPS: OS Windows XP and 2008R2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

明月夜 2024-12-27 11:53:40

http://cx-oracle.sourceforge.net/html/session_pool.html

注意 该对象是 DB API 的扩展,仅在 Oracle 9i 中可用。

http://cx-oracle.sourceforge.net/html/session_pool.html

Note This object is an extension the DB API and is only available in Oracle 9i.

囚我心虐我身 2024-12-27 11:53:40

我昨天也有同样的症状:在带有会话池的多线程应用程序中,有时释放会话会挂起长达 2 分钟。

您可能遇到以下 Oracle 错误之一:

错误 10157313 - 使用 OCI 会话池时 CPU 使用率过高且 OCISessionRelease 性能较差(文档 ID 10157313.8)

错误 10157313:使用 11.2 时,OCI 会话池会增加 CPU 使用率并需要很长时间才能释放

有关详细信息,请参阅 Oracle Metalink。

将 Oracle 客户端软件更新到 11.2.0.3 或更高版本(例如 InstantClient 11.2.0.3)似乎会有所帮助。

I had the same symptoms yesterday: In a multi-threaded application with a session pool, sometimes releasing the session hangs for up to 2 minutes.

You are probably hitting one of the following Oracle bugs:

Bug 10157313 - Excessive CPU usage and poor performance of OCISessionRelease when using OCI session pooling (Doc ID 10157313.8)

Bug 10157313 : OCI SESSION POOLING INCREASE CPU USAGE AND TAKE LONG TO RELEASE WHEN USING 11.2

For details see Oracle Metalink.

Updating the Oracle client software to 11.2.0.3 or later (eg InstantClient 11.2.0.3) seems to help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文