What Happens To a Query If It Times Out?

前端 未结 5 588
广开言路
广开言路 2020-12-16 15:34

Let\'s say I have a query that is sent to my SQL-Server database, it takes more than 30 seconds, and my program throws an SQL Query Timeout exception. Is the query still ch

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 16:14

    When the client decides that the command has run long enough, it issues an "Abort". The query simply stops running in the database.

    Any CATCH block won't be hit, transactions will be left open and locks can still remain allocated after this, even if the connection is closed because "close" means "return to connection pool".

    If you expect a lot of Command Timeouts then consider using SET XACT_ABORT ON (and this too) that will release locks and rollback transactions. or fix the code...

提交回复
热议问题