Failover fails when network cable unplugged.

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Magnus van Aardt
Posts: 3
Joined: Tue 13 Apr 2010 06:26

Failover fails when network cable unplugged.

Post by Magnus van Aardt » Tue 13 Apr 2010 06:46

Hi
I'm currently running SQL 2005 Mirroring setup. Using a simple app that just connect to the current principal database of the mirroring pair.
MSConnection is setup with the connection string pointing to the principal server.
On the TMSConnection object the Failoverpartner and localfailover values is specified. All that the app does is it loads all the record from a single table in the database to a grid, using a query component and the msconnection.
Using SDAC 4 with Delphi 5.
App is running on PC1 that link to the principal DB on PC2 with the mirror on PC3.

When using the failover option in SQL to force failover of the databses, the msconnection work 100%. the OnLostConnection event is raised and the connection is reconnected to the failOver server. If the failover is done back again everything still works. No problems there.

The problem occurs when the network cable is unplugged. The failover takes a couple of second longer(10seconds), where if the failover function in sql is used, the failover takes 1 or 2 seconds.
If I refresh the grid data as soon as I unplug the cable, there is a delay, connection time out period, and then I get the error 'TCP Provider: The semaphore timeout period has expired'. If I try the refresh the dataset again the I get the error 'Communication link failure. From then on it stays with the communication error. Not once did the OnLostconnection event fired to try and reconnect to the failOver server.

It seems that msconnection detects the network error, to the principal server, first and stops at that point and does not try to connect to the failover server. I can add code in the onerror event of msconnection to close and reconnect the connection, but is there a way to force msconnection to try a reconnect to the failover server when the communication link error occurs. The network link to the failover server is still up and running, it is only the principal server network link that died.

Regards
Magnus

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 13 Apr 2010 07:40

This behaviour is connected with the specificity of the Native Client work and we can't influence it. To solve the problem you can add your own processing in the OnError event handler.

Magnus van Aardt
Posts: 3
Joined: Tue 13 Apr 2010 06:26

Post by Magnus van Aardt » Tue 13 Apr 2010 09:58

Just something intresting.

If I unplug the cable and immediatly refresh the query, the Connection fail error is displayed. If I unplug the cable but wait for about 60 seconds and then refresh the query the failover is successfull. No communication link errors

Anyway thanks for the replay

hmelihkara
Posts: 21
Joined: Fri 09 Nov 2007 23:29

Re: Failover fails when network cable unplugged.

Post by hmelihkara » Thu 20 Feb 2014 00:28

I know this is an old thread but I've similar problem with one of my service applications.
Service app connected to database server (on different server) and if some communication problem has happened between database server and service server I got "Communication link failure". And the service application is giving error to all clients if I didn't restart it.

As you wrote it's related to native client, also as some MSFT wrote detailed cause of this problem here: http://social.msdn.microsoft.com/Forums ... baseengine

So what I wanna ask is simply disconnecting the TMSConnection can solve the problem?

If I wrote TMSConnection.Disconnect; inside OnError event, can this solve my problem. Also how can I learn the exact error code of "Communication link failure" error to write TMSConnection.Disconnect; code for specific error code.

Thanks...

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Failover fails when network cable unplugged.

Post by AlexP » Fri 21 Feb 2014 13:23

To retrieve the error code in the onError method you can use the E: EDAError: E.ErrorCode parameter and run the Disconnect method on an a particular error occurrence.

Post Reply