#1 2015-11-12 09:55:02

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

FireDAC - Connection: "MySQL Server has gone"

Hi AB

we got this message yesterday after a mormot service has run about 24 h
The reason seems to be a connection Timeout...

The Problem: it leads to unpredictable result's inserting new records (Exception comes retrieving next ID)

I inserted autoreconnect := true in SynDBFireDAC to test if this helps. May be you have another idea.

constructor TSQLDBFireDACConnection.Create(aProperties: TSQLDBConnectionProperties);
begin
  inherited Create(aProperties);
  fDatabase := TADConnection.Create(nil);
  fDatabase.ResourceOptions.SilentMode := True; // no need for wait cursor
  fDatabase.ResourceOptions.AutoReconnect := True; // itSDS Hande Reconnect on e.g. MySQL Server has gone
  fDatabase.Params.Text :=
    (fProperties as TSQLDBFireDACConnectionProperties).fFireDACOptions.Text;
end;

also i added ping in IsConnected

function TSQLDBFireDACConnection.IsConnected: boolean;
begin
  result := Assigned(fDatabase) and fDatabase.Ping and fDatabase.Connected;   // ItSDS PING added
end;

Further information can be found here:

http://docwiki.embarcadero.com/RADStudi … _(FireDAC)

Last edited by itSDS (2015-11-12 09:56:15)


Rad Studio 12.1 Santorini

Offline

#2 2015-11-12 11:22:45

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,603
Website

Re: FireDAC - Connection: "MySQL Server has gone"

Thanks for the feedback.
We would include those changes if it helps.

Did you try to use ConnectionTimeOutMinutes property of TSQLDBConnectionProperties ?
This generic property would recreate any connection after an idle period of time, at TSQLDBConnectionProperties level, i.e. for any kind of database access library.

Offline

#3 2015-11-12 13:14:39

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: FireDAC - Connection: "MySQL Server has gone"

I'll try - for this test i undocumented my modifications from above.


Rad Studio 12.1 Santorini

Offline

#4 2015-11-13 12:34:38

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: FireDAC - Connection: "MySQL Server has gone"

Hi AB, Setting ConnectionTimeOutMinutes  works perfekt. I testet it since yesterday
Since then the MySQL was shut down 2 times (for windows update) and the connection was restored automatically.
I'll have an eye on it!


Rad Studio 12.1 Santorini

Offline

Board footer

Powered by FluxBB