Page 1 of 1

Localfailover

Posted: Mon 14 Jan 2013 15:18
by pedja2
Hi,

I am using localfailover property to deal with bad networks, but last time customers getting first exception (Lost connection to mysql server...10054) and then after click on OK they get customized message 'Connection failed. Try to connect?'.

When they click on No at " ..Try to connect?" application start to blinks but not terminate?

I am using 7.5.10 version

Code: Select all

procedure TDM1.DB1ConnectionLost(Sender: TObject; Component: TComponent;
  ConnLostCause: TConnLostCause; var RetryMode: TRetryMode);
begin
if Connectionlost<20 then
 begin
  RetryMode:=rmReconnectExecute;
  Connectionlost:=Connectionlost+1;
 end
  else
   begin
    if MessageDlg('Connection failed. Try to connect?',mtConfirmation, [mbYes, mbNo], 0) = mrNo then
     begin
       Application.Terminate;
     end
      else
       begin
        Connectionlost:=0;
        RetryMode:=rmReconnectExecute;
       end;
   end;
end;
Regards

Re: Localfailover

Posted: Tue 15 Jan 2013 08:44
by AndreyZ
Hello,

The point is that MyDAC continues attempts to re-establish lost connection. To avoid the problem, you should set RetryMode to rmRaise before terminating your application. Here is a code example:

Code: Select all

...
if MessageDlg('Connection failed. Try to connect?',mtConfirmation, [mbYes, mbNo], 0) = mrNo then
begin
  RetryMode := rmRaise;
  Application.Terminate;
end
...

Re: Localfailover

Posted: Tue 15 Jan 2013 09:29
by pedja2
Hello,

this helps for blinks problem, but why i am getting first exception "Lost connection to MySQL server during query..." then customized message?

Regards

Re: Localfailover

Posted: Tue 15 Jan 2013 16:15
by AndreyZ
You will see the 'Lost connection to MySql server during query' error only if you run your application from IDE. You will not see this error when you run the executable file of your application.

Re: Localfailover

Posted: Wed 16 Jan 2013 10:05
by pedja2
Hello,

our customers don't have Delphi IDE, and also when I test with closed IDE I am getting first this error.

Regards

Re: Localfailover

Posted: Wed 16 Jan 2013 13:52
by AndreyZ
I cannot reproduce the problem. Please try creating a small sample to demonstrate the problem and send it to andreyz*devart*com .

Re: Localfailover

Posted: Thu 17 Jan 2013 08:47
by pedja2
weird...in small sample application everything works ok (customized message comes as first). In my application, same connection properties same query, error message comes as first.
Any idea?

Re: Localfailover

Posted: Thu 17 Jan 2013 15:25
by AndreyZ
I need a test project that demonstrates the problem. Without it, I will not be able to investigate the problem and give you a valid answer. Please try creating such project and send it to me.

Re: Localfailover

Posted: Fri 18 Jan 2013 13:04
by pedja2
I think i found the problem: Autoprepare

Use your own Failover demo project:
-set QUMaster Autoprepare property on true
-Failover combo on ReconnectExecute
-Connect
-Open
-Close
Shutdown mysql server
-Open
I am getting now direct error

Re: Localfailover

Posted: Fri 18 Jan 2013 15:30
by AndreyZ
The point is that the failover operation cannot be performed for prepared datasets. When you set the TMyQuery.Options.AutoPrepare property to True, TMyQuery is prepared on its opening. When you close prepared TMyQuery, it remains prepared. That is why the failover operation is not performed and you see the 'Lost connection to MySql server during query' error.
To avoid this problem, you should unprepare TMyQuery after its closing.