sql-server - "lock | communication buffer resources"是什么意思?

标签 sql-server sql-server-2008 deadlock database-deadlocks

我有一个错误日志报告死锁:

Transaction (Process ID 55) was deadlocked on lock | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

我正在尝试重现此错误,但我的标准死锁 SQL 代码会产生不同错误:

Transaction (Process ID 54) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

我想非常清楚地表明我不是在问什么是死锁。我确实了解基础知识。

我的问题是:lock | 的含义是什么?在这种情况下的通信缓冲区资源?什么是“通信缓冲资源”? lock | 有什么意义吗?

我最好的猜测是,当并行线程组合其结果时,会使用通信缓冲区。谁能证实或否认这一点?

我的最终目标是以某种方式触发第一个错误再次发生。

最佳答案

我会将该消息解释为锁定资源或通信缓冲区资源的某些组合上的死锁。 “锁资源”是普通对象锁,“通信缓冲区资源”是用于组合并行查询结果的交换事件。这些在https://blogs.msdn.microsoft.com/bartd/2008/09/24/todays-annoyingly-unwieldy-term-intra-query-parallel-thread-deadlocks/中有进一步描述。其中相关段落是:

An "exchangeEvent" resource indicates the presence of parallelism operators in a query plan. The idea is that the work for an operation like a large scan, sort, or join is divided up so that it can be executed on multiple child threads. There are "producer" threads that do the grunt work and feed sets of rows to "consumers". Intra-query parallel requires signaling between these worker threads: the consumers may have to wait on producers to hand them more data, and the producers may have to wait for consumers to finish processing the last batch of data. Parallelism-related waits show up in SQL DMVs as CXPACKET or EXCHANGE wait types (note that the presence of these wait types is normal and simply indicates the presence of parallel query execution -- by themselves, these waits don't indicate that this type or any other type of deadlock is occurring).

我见过的其中一个死锁图包括一组只有一个 SPID 的进程以及一个对象锁和交换事件图。我猜测消息“事务(进程 ID 55)在与另一个进程的锁 | 通信缓冲区资源上发生死锁,并已被选为死锁受害者。重新运行事务”出现,而不是“内部” -查询并行性导致您的服务器命令(进程 ID #51)死锁。由于对象锁和交换事件的组合,请使用查询提示选项 (maxdop 1) 重新运行没有查询内并行性的查询”,否则自本文撰写以来,该消息在 SQL Server 中已发生更改。

关于sql-server - "lock | communication buffer resources"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18996157/

相关文章:

sql - 如何在 SQL 2008 R2 的表中创建 AutoCounter 列?

sql - 如何替换sql server中的第n个字符

database - 记录 SQL Server 2008 中给定数据库的所有表中插入/更新/删除的行

c# - 导致死锁的异步/等待示例

c# - Azure 弹性数据库合并 GUI key 碎片

sql-server - sys.dm_database_encryption_keys 中的加密状态与 sys.databases 不一致

sql - 根据重复数据添加值

delphi - dbExpress 和 SQL Server 2008 速度慢

c# - Process.StandardOutput.ReadToEnd() 中的死锁问题;

Golang协程错误 "all goroutines are asleep - deadlock!"