How can have a SQL connection that is sleeping a pending transaction?

戏子无情 提交于 2020-01-03 03:39:07

问题


I'm facing some locks at our DB server created by our application. What I don't understand is how a process that is Sleeping is having an Open Transaction (that process 71 is the one creating the Lock).

As far as I know when a process finishes it closes all the opened transactions. Is that rigth?

Thanks in advance mates.


回答1:


As far as I know when a process finishes it closes all the opened transactions. Is that right?

No. If you explicitly open a transaction you must explicitly commit or rollback. Until that time the transaction remains open so it is perfectly possible for a connection to be idle (not currently processing any task) but still have an uncommitted transaction.

Many people expect that an error will automatically roll back a transaction but this is not the case unless you have

set xact_abort on



回答2:


As far as I know when a process finishes it closes all the opened transactions. Is that rigth?

Yes. But it is not guaranteed and you should not rely on it. You must explicitly close the connection.



来源:https://stackoverflow.com/questions/4325021/how-can-have-a-sql-connection-that-is-sleeping-a-pending-transaction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!