开发者

I pull the plug on the client workstation, what happens to a long running database process? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

SQL Server and connection loss in the middle of a transaction

I have a .NET 3.5 cli开发者_如何学JAVAent app that kicks off a long-running (5-10 m) stored proc on the MS SQL Server 2005. The stored proc starts with BEGIN TRAN and ends with COMMIT TRAN.

If I pull the plug on the workstation, what happens to the stored procedure, does it finish running? Does it finish running under all the circumstances? Or will the loss of connectivity with the workstation cause the database to abort the stored proc?

EDIT: The workstation and the SQL Server are on different boxes.


The loss of the workstation's power won't necessarily cause the SP to abort, but it could very well cause the transaction to roll back.

I say "could" because it does depend on exactly when the client loses its power. If a network connection is lost into a 'black hole' like this, the server won't be immediately notified that any disconnect happened at all; it has to rely on TCP eventually telling it that the connection is dead simply because the other side has not responded to anything in X time.

This is different from disconnecting the client application explicitly and 'normally'; in such a case, the client explicitly closes the connection, if applicable, and so SQL will know right away that the client is gone.


Since the stored procedure runs on the server, if the BEGIN/END TRANSACTION are part of that stored procedure the procedure should run to completion (barring any errors). The client will never receive any results, of course, since the connection was lost.


Somewhat similar; SQL Server and connection loss in the middle of a transaction

Be aware that connections aren't always shut down immediately, so unexpected behaviour must be anticipated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜