Oracle死锁没有显式锁定和读取已提交的隔离级别,为什么? [英] Oracle deadlock without explicit locking and read committed isolation level, why?

查看:80
本文介绍了Oracle死锁没有显式锁定和读取已提交的隔离级别,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使我没有使用任何显式表锁定并且我的隔离级别设置为READ COMMITTED,我仍然收到此错误Message: ORA-00060: deadlock detected while waiting for resource.

I get this error Message: ORA-00060: deadlock detected while waiting for resource even though I am not using any explicit table locking and my isolation level is set to READ COMMITTED.

在默认传播下,我在Spring TransactionTemplate上使用多个线程.在我的业务逻辑中,数据是分开的,因此两个事务永远不会拥有相同的数据集.因此,我不需要SERIALIZABLE

I use multiple threads over the Spring TransactionTemplate with default propagation. In my business logic the data is separated so that two transaction will never have the same set of data. Therefor I don't need SERIALIZABLE

为什么Oracle可以检测到死锁?在这个星座中,死锁是不可能的,还是我错过了什么?如果我什么都没错过,那么我的分离算法一定是错误的,对吧?还是可能有其他解释?

Why can Oracle detect a deadlock? Deadlocks are impossible in this constellation, or am I missing something? If I'm not missing anything then my separation algorithm must be wrong, right? Or could there be some other explaination?

推荐答案

Oracle默认情况下进行行级锁定.您提到使用多个线程.我怀疑一个线程正在锁定一行,然后尝试锁定另一条已经被另一线程锁定的行.然后,另一个线程尝试锁定第一个线程锁定的行.此时,Oracle将自动检测并打破死锁.上面提到的两行可以在同一表中,也可以在不同表中.

Oracle by default does row level locking. You mention using multiple threads. I suspect one thread is locking one row then attempting to lock another which has been locked by another thread. That other thread is then attempting to lock the row the first thread locked. At this point, Oracle will automatically detect a deadlock and break it. The two rows mentioned above could be in the same table or in different tables.

仔细研究每个线程的工作是起点.可能有必要决定不并行运行事物,或者可能必须使用显式锁定机制(例如,选择更新).

A careful review of what each thread is doing is the starting point. It may be necessary to decide to not run things in parallel, or it may be necessary to use an explicit locking mechanism (select for update for example).

LMK找到的内容以及其他任何问题…….

LMK of what you find and of any additional questions….

K

这篇关于Oracle死锁没有显式锁定和读取已提交的隔离级别,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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