[Q] Connection lost during post

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
DPStano
Junior Boarder
Junior Boarder
Posts: 39
Joined: 16.05.2016, 09:21

[Q] Connection lost during post

Post by DPStano »

just want to to know how to properly handle that situation when there is connection error during applyupdates call, I thought that i can catch error reconnect and apply updates again but reconnect will close all datasets

Edit:
I can create helper to prevent dataset closing

Code: Select all

procedure TZConnectionHelper.ForceReconnect;
begin
  if FConnection <> nil then
  begin
    DoBeforeReconnect;

    ShowSqlHourGlass;
    try
      try
        FConnection.Close;
      except
        Rollback; // decrement transaction count
      end;

      FConnection.Open;
    finally
      HideSqlHourGlass;
    end;

    DoAfterReconnect;
  end;
end;

with bellow changes in unit ZDbcInterbase6

procedure TZInterbase6Connection.Close;
begin
  if Closed or (not Assigned(PlainDriver)) then
     Exit;
  try
    try
      CloseTransaction;
    except
    end;

    if FHandle <> 0 then
    begin
      GetPlainDriver.isc_detach_database(@FStatusVector, @FHandle);
      FHandle := 0;
      CheckInterbase6Error(GetPlainDriver, FStatusVector, ConSettings, lcDisconnect);
    end;
  finally
    DriverManager.LogMessage(lcConnect, ConSettings^.Protocol,
      'DISCONNECT FROM "'+ConSettings^.DataBase+'"');

    inherited Close;
  end;
end;

i can make it works but when next Connection.Disconnect is called during program shutdown im getting errors like Disconnect, Error: Error reading data from the connection., Code: -902 (Unsuccessful execution caused by a system error that precludes successful execution of subsequent statements)
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: [Q] Connection lost during post

Post by marsupilami »

Hello DPStano,

I am afraid that Zeos is not built for that kind of use case. The problem here is that server ressources become invalid upon a disconnect. If you need a feature like that I would suggest to find a way to record your changes in a separate component - or maybe eben a TZQuery descandent, where you can reapply these changes after you reconnected again. Honestly my own applications simply die in a case like that...

With best regards,

Jan
Post Reply