开发者

How does SQL Server handle Network Failover in the middle of an insert statement

I am writing an Application that executes sql queries on a database in real time.

If I setup mirroring of the SQL Server and setup a FailoverPartner in the connection string and if the primary database goes down, will the secondary kick in automatically and therefore I do not have to re-open a conn开发者_如何学JAVAection or clear anything down?

Also how does it handle situations where a INSERT statement is running and the database goes down? Does the secodary pick it up or is it lost forever? Would it be safer to do transactional based insert statements?


Every form of High Availability (mirroring, clustering) will have a transaction boundary: every transaction in-flight at the moment of failover will be rolled back. This is not a limitation, is a feature. It would be impossible to write correct applications if this would not be true.

When a failover occurs, every connection using the database is cut. The clients have to re-establish new connections with the new principal, read again current state from the database and start applying new operations, on the current state. Correctly written applications (ie. transactional) will not have any issue with this. Only poorly coded apps can lose data.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜