Localfailover

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
pedja2
Posts: 29
Joined: Thu 04 Jun 2009 11:11

Localfailover

Post by pedja2 » Mon 14 Jan 2013 15:18

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

AndreyZ

Re: Localfailover

Post by AndreyZ » Tue 15 Jan 2013 08:44

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
...

pedja2
Posts: 29
Joined: Thu 04 Jun 2009 11:11

Re: Localfailover

Post by pedja2 » Tue 15 Jan 2013 09:29

Hello,

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

Regards

AndreyZ

Re: Localfailover

Post by AndreyZ » Tue 15 Jan 2013 16:15

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.

pedja2
Posts: 29
Joined: Thu 04 Jun 2009 11:11

Re: Localfailover

Post by pedja2 » Wed 16 Jan 2013 10:05

Hello,

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

Regards

AndreyZ

Re: Localfailover

Post by AndreyZ » Wed 16 Jan 2013 13:52

I cannot reproduce the problem. Please try creating a small sample to demonstrate the problem and send it to andreyz*devart*com .

pedja2
Posts: 29
Joined: Thu 04 Jun 2009 11:11

Re: Localfailover

Post by pedja2 » Thu 17 Jan 2013 08:47

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?

AndreyZ

Re: Localfailover

Post by AndreyZ » Thu 17 Jan 2013 15:25

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.

pedja2
Posts: 29
Joined: Thu 04 Jun 2009 11:11

Re: Localfailover

Post by pedja2 » Fri 18 Jan 2013 13:04

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

AndreyZ

Re: Localfailover

Post by AndreyZ » Fri 18 Jan 2013 15:30

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.

Post Reply