MySQL: Assertion failure after network reconnect

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
AEngel77
Posts: 2
Joined: Mon 21 May 2012 11:47

MySQL: Assertion failure after network reconnect

Post by AEngel77 » Mon 21 May 2012 12:01

Hi,

after the network was interrupted for a moment, appears in certain situations, the following error message:

Assertion failure (D:\Projects\Delphi\Dac\MySql\Source\MySqlApiDirect.pas, Zeile 580

What can I do, or what is said from the Assert?

Delphi 2009, MySQL, newest version of VCL UniDAC.

Thanks, André

AndreyZ

Re: MySQL: Assertion failure after network reconnect

Post by AndreyZ » Tue 22 May 2012 07:55

Hello,

This problem can be caused by incorrect working with threads. The right way to work in a multi-threaded application is to have connection (the TMyConnection component) in each thread. Please check that you have one connection in each thread.

AEngel77
Posts: 2
Joined: Mon 21 May 2012 11:47

Re: MySQL: Assertion failure after network reconnect

Post by AEngel77 » Wed 23 May 2012 12:51

Hi,

every thread has it's own connection. Normally everything works fine.

For connecting the MySQL-Server a SSH-Tunnel is used. Sometimes this tunnel disconnects when it has to be open.

My resolution: If I open a query I handle every connection-exception and try to reopen the SSH-Tunnel. After this I open the Query again. This worked already, perhaps with an older Version of UniDAC.

Now I get this assert when I try to Open the Query again. I already tried to do a disconnect when the error occurs, but this doesn't help.

Thx André

AndreyZ

Re: MySQL: Assertion failure after network reconnect

Post by AndreyZ » Thu 24 May 2012 09:22

To resume lost connection, you should use the TMyConnection.OnConnectionLost event handler. The OnConnectionLost event handler is used to process fatal errors and perform failover. To make the OnConnectionLost event handler work, you should set the TMyConnection.Options.LocalFailover property to True. Note that to use the OnConnectionLost event handler, you should add the MemData unit to the USES clause of your unit. Here is an example of using the OnConnectionLost event handler:

Code: Select all

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  MyConnection1.Options.LocalFailover := True;
  MyConnection1.Open;
end;

procedure TForm1.MyConnection1ConnectionLost(Sender: TObject;
  Component: TComponent; ConnLostCause: TConnLostCause;
  var RetryMode: TRetryMode);
begin
  RetryMode := rmReconnectExecute;
end;
In this case, if connection was lost, MyDAC will try to reconnect and reexecute the abortive operation. Please check if this approach solves the problem.

Post Reply