问题标签 [rowlocking]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
608 浏览

sql-server-2008 - Update - Select on same table creating deadlock

I am finding it difficult to find solution for this deadlock. The select query is taking shared lock over index I_SEM_AGENT_COMPUTER_ID_PLUS, at the same time update query updates a record (say r1) in table and then tries to update the index I_SEM_AGENT_COMPUTER_ID_PLUS (this index has columns in include clause that are updated by update query ) However select is requesting record r1 in shared mode. What can be possible solution to this? Apart from creating a new non-clustered index for select. Note: Dirty reads not allowed, READPAST can't be used as this can return no records failing purpose of select here

0 投票
1 回答
873 浏览

mysql - 用 SELECT 更新,它会锁定每一行还是所有 SELECTed 记录

我不清楚(通过阅读 MySQL 文档)以下查询是否在 MySQL 5.1 上的 INNODB 表上运行,是否会为数据库内部更新的每一行(总共 5000 行)创建 WRITE LOCK 或 LOCK 批处理中的所有行。由于数据库的负载非常重,这非常重要。

我希望它是每行的,但由于我不知道如何确保它是这样,所以我决定问一个有更深知识的人。如果不是这种情况并且数据库会锁定集合中的所有行,如果您能解释一下原因,我将不胜感激。

0 投票
5 回答
10965 浏览

mysql - How do I lock on an InnoDB row that doesn't exist yet?

How can I guarantee that I can search if a username exists in my database, then insert that username into the database as a new row without any intercept between the SELECT and INSERT statements?

Almost as if I am locking on a row that doesn't exist. I want to lock on the non-existent row with the username "Foo", so that I can now check if it exists in the database AND insert it into the database if it doesn't already exist without any interruption.

I know that using LOCK IN SHARE MODE and FOR UPDATE exist but as far as I know, that only works on rows that already exist. I am not sure what to do in this situation.

0 投票
1 回答
1061 浏览

oracle - oracle:释放单行上的锁(同时保留其他行上的锁)?

使用 Oracle 可以(使用单个数据库连接):

  1. 锁定单行 (row1)
  2. 然后锁定另一行(row2)
  3. 释放 row1 上的锁(保留 row2 上的锁)
  4. 获得另一行(row3)的锁
  5. 释放 row2 上的锁(保留 row3 上的锁)
  6. 释放第 3 行的锁

我意识到 Oracle 支持许多不同类型的锁(我发现这很有帮助:http ://broadh2o.net/docs/database/oracle/oracleLocks.html ),所以答案可能取决于选择哪种锁。我对独占锁感兴趣——即阻止其他连接更新行的锁。

我想知道我是否可以使用单个数据库连接执行操作 1-6。我当然可以为每一行使用单独的数据库连接。似乎锁是使用 COMMIT/ROLLBACK 释放的,因此这表明不可能释放单行上的锁。

0 投票
2 回答
4198 浏览

sql - 两个不同的事务同时更新同一个表的不同行

环境:SQL SERVER 2008 R2,Windows。

CONNECTION-1:执行以下操作


CONNECTION-2:执行以下


问题陈述:我通过 SQL Server Management Studio 执行上述事务,同时与同一台机器上的同一服务器/数据库建立两个连接。虽然表是相同的 & 事务同时执行(不是 100% 同时执行,因为手动执行)但是更新不同的行(行级锁定)那么为什么“Conneciton-2”事务没有立即提交并进入等到第一个事务未提交/完成。??

如果我没有清楚地描述我的场景,请告诉我。

0 投票
1 回答
166 浏览

mysql - 数据锁定阻止查询运行 - MySQL InnoDB

我们需要每 24 小时运行一次脚本,计算来自 1 个大日志表的数据的总和和平均值,并更新 Main_Table(Innodb)中的数据,该表一直有许多选择/更新查询(大约每秒 1 次)

我在本地数据库上运行了大约 10 分钟的测试查询:

并且因为这会更新 Main_Table 中的所有行,所以我猜由于表 loacking,所有内容都会卡在实时项目中 - 我必须终止查询过程才能再次开始正常工作 - 没有更新任何数据。

我做了一些挖掘,我正在考虑以下 3 个选项:

  1. 更新临时表中的所有数据,然后以某种方式合并到 Main_Table 中。
  2. 在 php 循环中运行脚本,而不是 1 个 MySql 查询(将花费更多时间,但一次更新 1 行)。
  3. 我不确定这是否与我们的问题有关,但我读到了一些关于“开始交易......等”的东西,我认为这可能是相关的......是吗?

希望有人能对此有所了解并帮助我们。谢谢

0 投票
2 回答
2705 浏览

multithreading - oracle row contention causing deadlock errors in high throughtput JMS application

Summary:

I am interested in knowing what's the best practice for high throughput applications that have bulk messages trying to update the same row and get oracle deadlock errors. I know you cannot avoid those errors but how do you recover from them gracefully without getting bogged down by such deadlock errors happening over and over again.

Details:

We are building a high throughput JMS messaging application. Production environment will be two weblogic 11g nodes (running 6 MDB listener instances each). We were getting Oracle deadlock errors (ORA-00060) when we get around 1000 messages all trying to update the same row in oracle database. Java synchronization across nodes is not possible in standard java threading API (unless there's no other solution we don't want to use any 3rd party solutions like terracotta etc).

We were hoping Oracle "select for update WAIT n secs" statement will help because that will essentially make the competing threads (for the same row) wait few seconds before the first thread (who got the lock on the row first) gets done with it.

First issue with "SELECT FOR UPDATE WAIT n" is it doesn't allow using milliseconds for wait times. This starts negatively affecting our application's throughput because putting 1 sec WAIT (least wait time) causes delays on the messages.

Second thing we are fiddling with weblogic queue re-delivery delay parameter (30 secs in our case). Whenever a thread bounces back because of the deadlock error, it will wait 30 seconds before being re-tried.

In our experience 1000 competing messages, in a lot of situations take forever to get processed because the deadlock keeps on happening over and over.

I understand that with the current architecture we are supposed to get deadlock errors regardless ( in case of 1000 competing messages) but application should be resilient enough to recover from these errors after retrying the looping messages.

Any idea what we are missing here ? anybody who has dealt with similar issues before?

I am looking for some design ideas that can make this work resiliently so that it recovers from this deadlock situation and eventually processes all messages in reasonable amount of time without using much additional hardware.

COMPUTATION DETAILS: These 1000 messages will EACH create 4 objects of 4 different position types each having a quantity associated with it. These quantities will have to merged into those 4 different slots (depending on the position type). The deadlock is happening when those 4 individual slots are being updated by each individual thread. We have already ordered those individual updates in a specific order before being applied to the database rows to avoid any possible race conditions.

0 投票
1 回答
432 浏览

sybase - Sybase 使用 iSQL 使用 WriteNoPK 读取行

我正在使用 Sybase SQL Anywhere 12。假设我有一个 Table 用户,与它有以下连接:

如果我现在要从 Sybase SQL Anywhere 中选择 * FROM 用户,我将按预期获取所有行和数据。

但是,如果我要在 OpenSuse 11.4 上使用 iSQL 中的 DBA 用户触发相同的 SQL 语句,则语句会运行并且我会收到结果,直到将要选择的行设置了 WriteNoPK-Lockflag。该声明比陈述以下错误:

服务器消息号=8405 严重性=21 状态=0 行=0 文本=SQL Anywhere 错误 -210: 用户 'XYZ' 锁定了 'user' 中的行,SQL: 'SELECT * FROM user'

即使该行是 WriteNoPK-Locked,是否有可能读取/选择?

非常感谢,马克斯

0 投票
2 回答
306 浏览

sybase - Unix FreeTDS Isolation Level Sybase

According to the Sybase Documentation (http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.sqlanywhere.12.0.1/dbusage/udtisol.html) there is one paragraph:

[...] The default isolation level is 0, except for [...] and TDS connections, which have a default isolation level of 1. [...]

Im connecting to that server using FreeTDS on Unix. Till now I haven't found a solution to change the Isolation-Level to 0 (Read-Uncommitted) (maybe using /etc/freetds.conf but here I also haven't found anything). For me its not possible to modify SQL-Statements so I'm looking for a config-option.

Anyone an idea?

0 投票
0 回答
184 浏览

oracle9i - Oracle 9i 数据库 - ORA-00054 资源忙

寻求一些建议。昨天,一位同事试图通过 Toad 更新 Oracle 9i 数据库中的一行。她在任务管理器中杀死了蟾蜍,因为它挂着没有响应。现在,当我们尝试更新行时,我们得到 ORA-00054: resource busy and acquire with NOWAIT specified。我们使用已断开的 VPN 连接访问数据库。我不是 DBA,但我认为 oracle 会在一段时间后清理任何旧会话/锁定?有什么办法可以解决这个问题,还是我应该联系 DBA 看看?