事务锁定插入语句

发布于 2024-11-18 23:52:16 字数 216 浏览 1 评论 0原文

我有一个外部分布式事务,它将一条插入语句锁定(挂起)到表中。 我无法控制外部交易。如何在非常细粒度的级别上避免这种阻塞。我尝试将事务抑制置于 .net 级别的插入周围。它不起作用。

请查看图片以获取详细信息。

此类问题的任何解决方案都可能非常有帮助在此处输入图像描述。我感谢您的支持。

I have an outer distributed transaction which is locking (Hanging) an insert statement to a table.
I don't have control over the outer transaction. How to avoid this blocking at the very granular level. I tried to put Transaction Suppress around that insert at .net level. It didn't work.

Please look at the image for detailed information.

Any solution to this kind of issue could be very helpfulenter image description here. I appreciate your support.

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

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

发布评论

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

评论(1

绅士风度i 2024-11-25 23:52:16

如果两个操作所关注的内容之间存在很强的交叉,并且不在同一事务中,那么这种情况是可以预料到的。外部事务可能采用了导致块的键范围锁(猜测外部事务是“可序列化”隔离级别)。这里你实际上无能为力,除了:

  • 在同一个事务中登记/操作,而不是在它之外操作,它
  • 会降低外部操作的隔离级别,因此
  • 如果外部操作是 , 则不会生成键范围锁查询(选择,而不是插入/更新/删除),然后使用 NOLOCK 或类似的方法来避免锁定它)

如果你不能做任何这些事情,那么你不能 插入时不破坏完整性 - 所以它不会让你这样做。您可能需要考虑推迟插入,直到外部操作完成。

That is expected if there is a strong crossover between what the two operations are looking at, and aren't in the same transaction. The outer transaction has presumably taken a key-range lock that is causing the block (at a guess the outer transaction is "serializable" isolation-level). There is nothing you can really do here, except:

  • enlist/operate in the same transaction, rather than operate outside it
  • lower the isolation level of the outer operation, so no key-range lock is generated
  • if the outer operation is a query (a select, not an insert/update/delete), then use NOLOCK or similar to avoid locking it)

if you can't do any of those things, then you can't insert without breaking integrity - so it won't let you. You might want to consider deferring the insert until the outer operation has comlpleted.

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