oracle ORA-00054 错误的原因是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10350821/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the reason for ORA-00054 error?
提问by AppleGrew
From Oracle's documentation:-
来自 Oracle 的文档:-
ORA-00054 resource busy and acquire with NOWAIT specified
Cause: Resource interested is busy.
Action: Retry if necessary.
In our code we issue a SELECT FOR UPDATE NOWAIT
command to lock the row we are about to update.
在我们的代码中,我们发出一个SELECT FOR UPDATE NOWAIT
命令来锁定我们将要更新的行。
Right now the logic is if it returns SQL error 54
then it is assumed that another user is trying to update that same record. Is this logic valid?
现在的逻辑是,如果它返回 SQL 错误54
,则假定另一个用户正在尝试更新相同的记录。这个逻辑有效吗?
From Oracle's documentation it looks more like if the DB is overwhelmed then this might also cause this error to be thrown.
从 Oracle 的文档看来,如果 DB 不堪重负,那么这也可能会导致抛出此错误。
What are the possible reasons for this error, when we are only using the above SQL command?
当我们只使用上面的SQL命令时,出现这个错误的可能原因是什么?
回答by David Aldridge
The SELECT ... FOR UPDATE attempts to acquire an RS (Row Share) lock on the table and an X (eXclusive) lock on the row. If another session has an exclusive lock on the table (eg creating an index) or an exclusive lock on the row (update, delete, or select for update) then the query will wait for the other transaction to release the lock (commit or rollback generally) unless you have specified NOWAIT.
SELECT ... FOR UPDATE 尝试获取表上的 RS(行共享)锁和行上的 X(排他)锁。如果另一个会话在表上有排他锁(例如创建索引)或在行上有排他锁(更新、删除或选择更新),那么查询将等待另一个事务释放锁(提交或回滚)通常)除非您指定了 NOWAIT。
So one possibility is to not specify NOWAIT.
所以一种可能性是不指定 NOWAIT。
I don't recognise the situation where the database might throw this error due to being "overwhelmed".
我不知道数据库可能会因“不堪重负”而引发此错误的情况。