在oracle.jdbc.driver.T4CConnection上找到的锁定对象 [英] Locked object found on oracle.jdbc.driver.T4CConnection

查看:4928
本文介绍了在oracle.jdbc.driver.T4CConnection上找到的锁定对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JMC执行应用程序分析,我没有看到任何锁定/线程争用,如下面的屏幕截图所示。

I am using JMC to perform application profiling and I did not see any locked/thread contention as shown in the screenshot below.




我在下面运行SQL(每隔几秒) )也没有返回任何结果。

I ran the SQL below (every few secs) also did not return any result.

select 
   (select username from v$session where sid=a.sid) blocker,
   a.sid,
   ' is blocking ',
   (select username from v$session where sid=b.sid) blockee,
   b.sid
from 
   v$lock a, 
   v$lock b
where 
   a.block = 1
and 
   b.request > 0
and 
   a.id1 = b.id1
and 
   a.id2 = b.id2;

锁定数据库连接可能是什么原因造成的?它可能是数据库记录/表锁吗?

What could be the caused of a lock database connection? Could it be database record/table locks?

下面是我在程序执行期间提取的线程转储,它似乎永远在运行。

Below is the thread dump which I have extracted during the execution of my program when it seems to be running forever.

   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
    at java.net.SocketInputStream.read(SocketInputStream.java:170)
    at java.net.SocketInputStream.read(SocketInputStream.java:141)
    at oracle.net.ns.Packet.receive(Packet.java:283)
    at oracle.net.ns.DataPacket.receive(DataPacket.java:103)
    at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:230)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:175)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:100)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:85)
    at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:123)
    at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:79)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1122)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1099)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:288)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
    at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:863)
    at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
    - locked <0x00000007af3423c0> (a oracle.jdbc.driver.T4CConnection)


推荐答案

你这里混淆数据库锁和Java锁。 JMC只显示Java程序中的锁(同步块,等待等),它对数据库内部的内容一无所知。您的SQL查询仅显示数据库级别的锁(表锁,行锁等),并且不了解Java程序中的锁。这些是绝对不同的区域和完全不同的锁。

You're confusing database locks with Java locks here. JMC only shows you the locks inside your Java program (synchronized blocks, waits etc), it knows nothing about what's going on inside your DB. Your SQL-query only shows the locks on the DB level (table locks, row locks etc) and knows nothing about the locks inside your Java program. Those are absolutely different areas and absolutely different locks.

这里有一个线程的转储,它对类型的对象持有一个锁T4CConnection ,地址 0x7af3423c0 。它只表示此线程正在执行某些 synchronized(连接)块中的代码。就这样。该线程未被其他线程阻止(否则其状态将不是 RUNNABLE ,它将是 WAITING BLOCKED )。它正在运行并从网络套接字中读取内容(可能是来自数据库的响应)。

What you have here is a dump of a thread that holds a lock on the object of type T4CConnection with the address 0x7af3423c0. It only means that this thread is in the process of executing a code inside some synchronized(connection) block. That's all. The thread is not blocked by other threads (otherwise its state wouldn't be RUNNABLE, it would be WAITING or BLOCKED). It's running and reading something from a network socket (probably, the response from the DB).

这种行为绝对正常。数据库驱动程序在连接实例上执行同步,而它正在执行SQL查询以不允许其他线程并行使用它。

Such behaviour is absolutely normal. The DB driver does synchronization on the connection instance while it's in the process of executing an SQL-query to not allow other threads to use it in parallel.

你没有什么应该做的担心这个截图和这个线程转储。

There's nothing you should worry about on this screenshot and in this thread dump.

这篇关于在oracle.jdbc.driver.T4CConnection上找到的锁定对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆