如何在 TransactionScope 中解锁被父进程 (Insert Stmt) 阻止的进程 (Insert Stmt)

发布于 2024-08-17 12:25:01 字数 529 浏览 6 评论 0原文

我在父 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 技术交流群。

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

发布评论

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

评论(1

勿忘初心 2024-08-24 12:25:01

如果每个 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...

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