10060 connection lost when MyLoader is loading data

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
applespring
Posts: 22
Joined: Tue 15 May 2012 14:01

10060 connection lost when MyLoader is loading data

Post by applespring » Wed 28 Jun 2017 06:15

Hello

I have met a strange problem, when I use TMyLoader to loading a large amount of data (1000 columns, 100k rows) into MySQL table, I will have an error of "Lost connection to MySQL server during query....Socket Error Code: 10060($274C)"

while searching this error code, this should happened during the connection establishment, while I have already connected to the MySQL server before TMyLoader.Load is called.

So I was wondering where could be the problem? Does TMyLoader will reconnect to MySQL server during the load? What interaction between TMyLoader and MySQL server can cause this 10060 error?

MySQL version: 5.6.14-log
MyDAC version: 8.7.27
Delphi: XE2
Windows: Win Server 2008 R2

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: 10060 connection lost when MyLoader is loading data

Post by ViktorV » Fri 30 Jun 2017 08:49

Given WSAETIMEDOUT(10060) error arises when the connected host has failed to respond. You can read about the WSAETIMEDOUT(10060) error in more details in MSDN.
Usually this error is related to network problems or firewall settings.
A connection to MySQL server can be lost due to connection activity timeout specified in the system variable wait_timeout of MySQL server.
Also the connection can be lost when inserting large data due to server settings.
To load big data you need to increase the server variable value max_allowed_packet in the my.ini file and restart the server.

For example:
max_allowed_packet = 16M
More details here:
http://dev.mysql.com/doc/refman/5.0/en/ ... ables.html
http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

To restore a lost connection you need to use the event handler TMyConnection.OnConnectionLost. To enable the OnConnectionLost event handler set the property TMyConnection.Options.LocalFailover to True. Please note to use the OnConnectionLost handler you need to add the MemData unit to the USES section of your unit. An example of using OnConnectionLost:

Code: Select all

procedure TForm1.Button1Click(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 when connection is lost MyDAC will try to reconnect and restart the failed operation. Read more in MyDAC documentation: https://www.devart.com/mydac/docs/Devar ... onLost.htm

Post Reply