我的 Java 程序在调用 oracle.jdbc.pool.OracleOCIConnectionPool.getConnection 时冻结了几分钟

发布于 2024-10-11 21:30:39 字数 5888 浏览 3 评论 0原文

我有一个连接到 oracle 11g 的 Java 应用程序。该进程在 oracle.jdbc.pool.OracleOCIConnectionPool.getConnection 方法处冻结 2 到 3 分钟。不过,它确实成功获得了连接,并在 3 分钟后继续,没有任何错误。

奇怪的是,当连接到同一个数据库时,同一个程序可以在不同的机器上正常运行。

我不明白这里发生了什么事。有人可以帮我解决这个问题吗?

下面是示例程序卡在 getConnection 方法时的线程转储:

Full thread dump Java HotSpot(TM) Server VM (1.5.0_11-b03 mixed mode):

"Thread-9" prio=10 tid=0x00431a60 nid=0x24 runnable [0xaffff000..0xaffffb70]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-8" prio=10 tid=0x00430e50 nid=0x23 runnable [0xb00ff000..0xb00ff9f0]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-7" prio=10 tid=0x00460490 nid=0x22 runnable [0xb01ff000..0xb01ffa70]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-6" prio=10 tid=0x00249320 nid=0x21 runnable [0xb02ff000..0xb02ff8f0]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-5" prio=10 tid=0x000b7910 nid=0x20 runnable [0xb03ff000..0xb03ff970]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-4" prio=10 tid=0x000b7128 nid=0x1f runnable [0xb04ff000..0xb04ffbf0]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-3" prio=10 tid=0x00126a50 nid=0x1e runnable [0xb05ff000..0xb05ffc70]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-2" prio=10 tid=0x0058bc38 nid=0x1d runnable [0xb06ff000..0xb06ffaf0]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-1" prio=10 tid=0x00125d90 nid=0x1c runnable [0xb07ff000..0xb07ffb70]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Low Memory Detector" daemon prio=10 tid=0x001c5f50 nid=0x19 runnable [0x00000000..0x00000000]

"CompilerThread1" daemon prio=10 tid=0x001c4de8 nid=0x18 waiting on condition [0x00000000..0xb347e8b4]

"CompilerThread0" daemon prio=10 tid=0x001c3f70 nid=0x17 waiting on condition [0x00000000..0xb357e93c]

"AdapterThread" daemon prio=10 tid=0x001c30f8 nid=0x16 waiting on condition [0x00000000..0x00000000]

"Signal Dispatcher" daemon prio=10 tid=0x001c2388 nid=0x15 waiting on condition [0x00000000..0x00000000]

"Finalizer" daemon prio=10 tid=0x001b5b80 nid=0x14 in Object.wait() [0xb387f000..0xb387faf0]
        at java.lang.Object.wait(Native Method)
        - waiting on <0xe30006d8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
        - locked <0xe30006d8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x001b4e38 nid=0x13 in Object.wait() [0xb397f000..0xb397fb70]
        at java.lang.Object.wait(Native Method)
        - waiting on <0xe30005e8> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:474)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
        - locked <0xe30005e8> (a java.lang.ref.Reference$Lock)

"main" prio=10 tid=0x00036898 nid=0x1 runnable [0xffbfc000..0xffbfcf30]
        at oracle.jdbc.driver.T2CConnection.t2cConnPoolLogon(Native Method)
        at oracle.jdbc.driver.T2CConnection.processOCIConnectionPooling(T2CConnection.java:1103)
        at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:258)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
        at oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:148)
        at oracle.jdbc.driver.OracleOCIConnection.<init>(OracleOCIConnection.java:60)
        at oracle.jdbc.driver.OracleOCIConnection.<init>(OracleOCIConnection.java:44)
        at oracle.jdbc.oci.OracleOCIConnection.<init>(OracleOCIConnection.java:35)
        at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:49)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
        at oracle.jdbc.pool.OracleOCIConnectionPool.getConnection(OracleOCIConnectionPool.java:244)
        - locked <0xe3272a78> (a oracle.jdbc.pool.OracleOCIConnectionPool)
        at conPoolAppl.main(conPoolAppl.java:47)

"VM Thread" prio=10 tid=0x001b2d58 nid=0x12 runnable

"GC task thread#0 (ParallelGC)" prio=10 tid=0x000b8148 nid=0x2 runnable

"GC task thread#1 (ParallelGC)" prio=10 tid=0x000b8b88 nid=0x3 runnable

"GC task thread#2 (ParallelGC)" prio=10 tid=0x000b95c8 nid=0x4 runnable

"GC task thread#3 (ParallelGC)" prio=10 tid=0x000ba008 nid=0x5 runnable

"GC task thread#4 (ParallelGC)" prio=10 tid=0x000baa48 nid=0x6 runnable

"GC task thread#5 (ParallelGC)" prio=10 tid=0x000bb488 nid=0x7 runnable

"GC task thread#6 (ParallelGC)" prio=10 tid=0x000bbee0 nid=0x8 runnable

"GC task thread#7 (ParallelGC)" prio=10 tid=0x000bd128 nid=0x9 runnable

"GC task thread#8 (ParallelGC)" prio=10 tid=0x000bdb68 nid=0xa runnable

"GC task thread#9 (ParallelGC)" prio=10 tid=0x000be5a8 nid=0xb runnable

"GC task thread#10 (ParallelGC)" prio=10 tid=0x000befe8 nid=0xc runnable

"GC task thread#11 (ParallelGC)" prio=10 tid=0x000bfa28 nid=0xd runnable

"GC task thread#12 (ParallelGC)" prio=10 tid=0x000c0468 nid=0xe runnable

"GC task thread#13 (ParallelGC)" prio=10 tid=0x000c0ea8 nid=0xf runnable

"GC task thread#14 (ParallelGC)" prio=10 tid=0x000c18e8 nid=0x10 runnable

"GC task thread#15 (ParallelGC)" prio=10 tid=0x000c2328 nid=0x11 runnable

"VM Periodic Task Thread" prio=10 tid=0x001c71e0 nid=0x1a waiting on condition

I have a Java app which connects to oracle 11g. The process freezes for 2 to 3 minutes at the oracle.jdbc.pool.OracleOCIConnectionPool.getConnection method. It does manage to get the connection and continues without any error after the 3 minutes time though.

The weird bit of this is that the same program runs fine from a different machine when connecting to the same database.

I can't figure out what is going on here. Can any one help me out with this?

Below is the thread dump of the a sample program when it is stuck at the getConnection method:

Full thread dump Java HotSpot(TM) Server VM (1.5.0_11-b03 mixed mode):

"Thread-9" prio=10 tid=0x00431a60 nid=0x24 runnable [0xaffff000..0xaffffb70]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-8" prio=10 tid=0x00430e50 nid=0x23 runnable [0xb00ff000..0xb00ff9f0]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-7" prio=10 tid=0x00460490 nid=0x22 runnable [0xb01ff000..0xb01ffa70]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-6" prio=10 tid=0x00249320 nid=0x21 runnable [0xb02ff000..0xb02ff8f0]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-5" prio=10 tid=0x000b7910 nid=0x20 runnable [0xb03ff000..0xb03ff970]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-4" prio=10 tid=0x000b7128 nid=0x1f runnable [0xb04ff000..0xb04ffbf0]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-3" prio=10 tid=0x00126a50 nid=0x1e runnable [0xb05ff000..0xb05ffc70]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-2" prio=10 tid=0x0058bc38 nid=0x1d runnable [0xb06ff000..0xb06ffaf0]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Thread-1" prio=10 tid=0x00125d90 nid=0x1c runnable [0xb07ff000..0xb07ffb70]
        at java.lang.Thread.yield(Native Method)
        at conPoolAppl.run(conPoolAppl.java:101)

"Low Memory Detector" daemon prio=10 tid=0x001c5f50 nid=0x19 runnable [0x00000000..0x00000000]

"CompilerThread1" daemon prio=10 tid=0x001c4de8 nid=0x18 waiting on condition [0x00000000..0xb347e8b4]

"CompilerThread0" daemon prio=10 tid=0x001c3f70 nid=0x17 waiting on condition [0x00000000..0xb357e93c]

"AdapterThread" daemon prio=10 tid=0x001c30f8 nid=0x16 waiting on condition [0x00000000..0x00000000]

"Signal Dispatcher" daemon prio=10 tid=0x001c2388 nid=0x15 waiting on condition [0x00000000..0x00000000]

"Finalizer" daemon prio=10 tid=0x001b5b80 nid=0x14 in Object.wait() [0xb387f000..0xb387faf0]
        at java.lang.Object.wait(Native Method)
        - waiting on <0xe30006d8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
        - locked <0xe30006d8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x001b4e38 nid=0x13 in Object.wait() [0xb397f000..0xb397fb70]
        at java.lang.Object.wait(Native Method)
        - waiting on <0xe30005e8> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:474)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
        - locked <0xe30005e8> (a java.lang.ref.Reference$Lock)

"main" prio=10 tid=0x00036898 nid=0x1 runnable [0xffbfc000..0xffbfcf30]
        at oracle.jdbc.driver.T2CConnection.t2cConnPoolLogon(Native Method)
        at oracle.jdbc.driver.T2CConnection.processOCIConnectionPooling(T2CConnection.java:1103)
        at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:258)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
        at oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:148)
        at oracle.jdbc.driver.OracleOCIConnection.<init>(OracleOCIConnection.java:60)
        at oracle.jdbc.driver.OracleOCIConnection.<init>(OracleOCIConnection.java:44)
        at oracle.jdbc.oci.OracleOCIConnection.<init>(OracleOCIConnection.java:35)
        at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:49)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
        at oracle.jdbc.pool.OracleOCIConnectionPool.getConnection(OracleOCIConnectionPool.java:244)
        - locked <0xe3272a78> (a oracle.jdbc.pool.OracleOCIConnectionPool)
        at conPoolAppl.main(conPoolAppl.java:47)

"VM Thread" prio=10 tid=0x001b2d58 nid=0x12 runnable

"GC task thread#0 (ParallelGC)" prio=10 tid=0x000b8148 nid=0x2 runnable

"GC task thread#1 (ParallelGC)" prio=10 tid=0x000b8b88 nid=0x3 runnable

"GC task thread#2 (ParallelGC)" prio=10 tid=0x000b95c8 nid=0x4 runnable

"GC task thread#3 (ParallelGC)" prio=10 tid=0x000ba008 nid=0x5 runnable

"GC task thread#4 (ParallelGC)" prio=10 tid=0x000baa48 nid=0x6 runnable

"GC task thread#5 (ParallelGC)" prio=10 tid=0x000bb488 nid=0x7 runnable

"GC task thread#6 (ParallelGC)" prio=10 tid=0x000bbee0 nid=0x8 runnable

"GC task thread#7 (ParallelGC)" prio=10 tid=0x000bd128 nid=0x9 runnable

"GC task thread#8 (ParallelGC)" prio=10 tid=0x000bdb68 nid=0xa runnable

"GC task thread#9 (ParallelGC)" prio=10 tid=0x000be5a8 nid=0xb runnable

"GC task thread#10 (ParallelGC)" prio=10 tid=0x000befe8 nid=0xc runnable

"GC task thread#11 (ParallelGC)" prio=10 tid=0x000bfa28 nid=0xd runnable

"GC task thread#12 (ParallelGC)" prio=10 tid=0x000c0468 nid=0xe runnable

"GC task thread#13 (ParallelGC)" prio=10 tid=0x000c0ea8 nid=0xf runnable

"GC task thread#14 (ParallelGC)" prio=10 tid=0x000c18e8 nid=0x10 runnable

"GC task thread#15 (ParallelGC)" prio=10 tid=0x000c2328 nid=0x11 runnable

"VM Periodic Task Thread" prio=10 tid=0x001c71e0 nid=0x1a waiting on condition

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

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

发布评论

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

评论(1

薄荷→糖丶微凉 2024-10-18 21:30:40

使用 ltrace&strace (linux) 或 truss&dtrace (solaris) 查看本机代码正在做什么。

Use ltrace&strace (linux) or truss&dtrace (solaris) to see what the native code is doing.

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