Page 1 of 1

MySQL: Assertion failure after network reconnect

Posted: Mon 21 May 2012 12:01
by AEngel77
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é

Re: MySQL: Assertion failure after network reconnect

Posted: Tue 22 May 2012 07:55
by AndreyZ
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.

Re: MySQL: Assertion failure after network reconnect

Posted: Wed 23 May 2012 12:51
by AEngel77
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é

Re: MySQL: Assertion failure after network reconnect

Posted: Thu 24 May 2012 09:22
by AndreyZ
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.