Local Failover

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
michaschumann
Posts: 44
Joined: Fri 14 Nov 2014 15:26

Local Failover

Post by michaschumann » Thu 03 Mar 2016 19:03

I am using lacal failover with a database in disconnected mode, everything is autocommit and the datasets have the autoclose property and always fetchall.

The Database Connection sets:

On Error: Fail := false;
OnConnectionLost: RetryMode := rmReconnectExecute;

I simulate lost connction by stopping the firebird instance. I have two issues:

1. Even when I do nothing with the attached loaded datasets, after some time the reconnect event occures. Why? I assumed that in disconnected mode even updating is buffered with cachedUpdates.

2. If the connection is lost the application is completely frozen and "thaws" when the connection can be restored. Is it possible to have the UI responsive during that time?

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

Re: Local Failover

Post by ViktorV » Mon 14 Mar 2016 12:02

1. Reconnection to the server occurs only on calling it. IBDAC itself doesn't initialize attempts to call the server. Therefore, please compose a small sample reproducing the issue and send it to viktorv*devart*com - and we will tell you the reason for such behavior.
2. Application hanging occurs on an attempt to connect to the database. Therefore, to avoid program hanging, you can try to reconnect several times and stop attempts if reconnection fails. For example, you can use the following code:

Code: Select all

var
  RetryCount: Integer;

procedure TMainForm.IBCConnection1ConnectionLost(Sender: TObject;
  Component: TComponent; ConnLostCause: TConnLostCause;
  var RetryMode: TRetryMode);
begin
  if RetryCount < 2 then begin
    Inc(RetryCount);
    RetryMode := rmReconnectExecute;
  end
  else begin
    RetryCount := 0;
    RetryMode := rmRaise;
  end;
end;
In this case, IBDAC will attempt to restore connection twice and generate an exception in case of failure.

Post Reply