简体   繁体   English

强制事务从另一个连接提交?

[英]Force a Transaction to commit from another connection?

We have a very difficult to track down bug in one of our software solutions that sometimes leaves an open transaction. 在我们的某个软件解决方案中,我们很难找到有时会留下开放交易的错误。 We have this application in production at a number of sites (read: 70+), and we've only seen this issue twice so far this year at separate locations. 我们在许多网站上都有这个应用程序(阅读:70+),我们今年到目前为止在不同地点只看过两次这个问题。

The issue we're having is a transaction that's being left open from the constant connection to the SQL Server. 我们遇到的问题是从与SQL Server的持续连接中保持打开的事务。 Using dbcc opentran shows that there is a single transaction left open. 使用dbcc opentran显示只有一个事务处于打开状态。 In today's case, it was open from 9:30 AM before we realized it at 1:00 PM. 在今天的情况下,它是在我们在下午1点实现它之前从上午9:30开放的。 Closing the program with the connection will result in the transaction being closed/cancelled, and all the data from the day thus far lost. 使用连接关闭程序将导致事务被关闭/取消,并且迄今为止的所有数据都将丢失。

Using dbcc opentran it responds with the name of the open transaction was user_transaction . 使用dbcc opentran它响应与打开事务的名字是user_transaction Trying to close it with commit tran user_transaction gives an error of The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. 尝试使用commit tran user_transaction关闭它会产生错误commit tran user_transaction The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. .

I can understand you would almost never want to force the transaction to be committed without the prior connection's knowledge, but is there any way to do so? 我可以理解,如果没有先前的连接知识,你几乎不会强制提交事务,但有没有办法这样做? In this case, we closed the program and we lost a half of day's business worth of data. 在这种情况下,我们关闭了该计划,我们失去了半天的业务价值数据。

Thanks. 谢谢。

If it were possible for a transaction to be committed by another conenction, then it's not a transaction. 如果交易可能由另一个事件提交,那么它不是交易。 If this were possible, it would open the door to way more issues than it would solve. 如果这是可能的话,它将为解决更多问题打开大门。

See this link: http://ask.sqlservercentral.com/questions/3865/forcing-a-transaction-to-commit.html 请看这个链接: http//ask.sqlservercentral.com/questions/3865/forcing-a-transaction-to-commit.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM