的SqlTransaction已完成 [英] SqlTransaction has completed

查看:2731
本文介绍了的SqlTransaction已完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有可能做成千上万的插入到SQL Server 2005数据库的应用程序。如果插入任何原因失败(外键约束,字段长度等),应用程序设计来记录插入错误并继续。

I have an application which potentially does thousands of inserts to a SQL Server 2005 database. If an insert fails for any reason (foreign key constraint, field length, etc.) the application is designed to log the insert error and continue.

每个插入物都独立于其他的,因此不需要对数据库完整性的交易。然而,我们确实希望使用它们的性能增益。当我使用的交易,我们会得到下面的错误在约1,每100提交的。

Each insert is independent of the others so transactions aren't needed for database integrity. However, we do wish to use them for the performance gain. When I use the transactions we'll get the following error on about 1 out of every 100 commits.

本的SqlTransaction已完成;它不再可用。    在System.Data.SqlClient.SqlTransaction.ZombieCheck()    在System.Data.SqlClient.SqlTransaction.Commit()

This SqlTransaction has completed; it is no longer usable. at System.Data.SqlClient.SqlTransaction.ZombieCheck() at System.Data.SqlClient.SqlTransaction.Commit()

要设法追查我把在跟踪每一笔交易操作语句的原因,所以我可以保证交易没有被调用commit前关闭。我已经证实了我的应用程序wan't结束交易。 然后我跑了应用程序再次使用完全一样的输入数据,并且取得了成功。

To try to track down the cause I put trace statements at every transaction operation so I could ensure the transaction wasn't being closed before calling commit. I've confirmed that my app wan't closing the transaction. I then ran the app again using the exact same input data and it succeeds.

如果我打开注销再次失败。重新打开它,它成功。这种开/关切换经由在app.config而不需要重新编译完成。

If I turn the logging off it fails again. Turn it back on and it succeeds. This on/off toggle is done via the app.config without the need to recompile.

显然采伐的行为变化的时间,并导致它的工作。这表明一个线程问题。但是,我的应用程序是不是多线程。

Obviously the act of logging changes the timing and causes it to work. This would indicate a threading issue. However, my app isn't multi-threaded.

我见过一个MS KB的条目,表明与.net 2.0框架中的错误可能会导致类似的问题( HTTP://支持。 microsoft.com/kb/912732 )。然而,他们所提供的补丁没有解决这个问题。

I've seen one MS KB entry indicating a bug with .Net 2.0 framework could cause similar issues (http://support.microsoft.com/kb/912732). However, the fix they provided doesn't solve this issue.

推荐答案

感谢所有的反馈。我一直在与有人从MSFT在MSDN论坛弄清楚发生了什么事情。原来,这个问题是由于一个失败,由于日期时间转换问题的刀片。

Thanks for all the feedback. I've been working with someone from MSFT on the MSDN forums to figure out what's going on. It turns out the issue is due to one of the inserts failing due to a date time conversion problem.

的主要问题是,这个错误显示出来,如果​​它是一个日期转换错误。但是,如果它是另一个错误,如现场太长时间不会导致此问题。在这两种情况下,我希望该交易仍然存在,所以我可以调用回滚就可以了。

The major problem is the fact that this error shows up if it's a date conversion error. However, if it's another error such as a field being too long it doesn't cause this issue. In both cases I would expect the transaction to still exist so I can call Rollback on it.

我有一个完整的示例程序来复制这个问题。如果有人希望看到它或MSFT的交流,你可以找到关于MSFT的新闻组线程在SqlTransaction.ZombieCheck错误线程下microsoft.public.dotnet.framework.adonet。

I have a full sample program to replicate this issue. If anyone wishes to see it or the exchange with MSFT you can find the thread on MSFT's newsgroups in microsoft.public.dotnet.framework.adonet under the SqlTransaction.ZombieCheck error thread.

这篇关于的SqlTransaction已完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆