如何在 TransactionScope 中解锁被父进程 (Insert Stmt) 阻止的进程 (Insert Stmt)
我在父 TransactionSope
中有一个子 TransactionScope
。子 TransactionScope
在单父 TransactionScope
下多次创建、执行和提交。
父 TransactionScope 负责将单个记录插入数据库,同时等待第二组插入语句一一完成执行。
完成第一个事务后,在第一次插入子事务时出现问题。从昨天开始经过大量研究后,我现在发现第二个插入正在运行的进程被第一个插入的进程阻止了。
我通过在程序正在运行的 SQL Server 中运行 SP_WHO2
发现了这一点。
同时,插入过程中涉及的两个表之间存在一对多关系。第一个插入在父表上执行操作,而第二个插入将在子表上执行操作。
每当我删除两个表之间的关系约束时,事务都会经历,但当约束打开时则不会。
我的问题是如何解锁被第一个插入阻止的第二个进程?
I have a child TransactionScope
within a parent TransactionSope
. The child TransactionScope
is created, executed, and committed multiple times under the singular parent TransactionScope
.
The parent TransactionScope takes care of Insert
a single record into the database while waiting for the the second set of insert statements to complete execution one-by-one.
After completing the first transaction, on the first insert of the child transactions there was a problem. After a whole lot of research since yesterday, I would out now that the process that the second insert is running on is block by the first insert's process.
I found this out by running SP_WHO2
in sql server with the program was running.
Meanwhile, there is a one-many relationship between the two table involved in the insertion process. The first insert performs it's operation on the parent table while the second will be on the child table.
Whenever i remove the relationship constraint between the two tables the transaction goes through, but doesn't when the constraint is on.
My question is how to unblock the second process which is blocked by the first insert?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果每个 TransactionScope 使用不同的连接,那么这是预期的并且是设计使然。
现在,我不是 C# 专家,但是...
If each TransactionScope is using a different connection, then this is expected and by design.
Now, I'm not an expert in c# but...