Zeos 7.2.10 commit transaction closes all datasets

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
StTu
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 14.06.2021, 09:09

Zeos 7.2.10 commit transaction closes all datasets

Post by StTu »

Hi,

we are using cached updates like and after update to 7.2.10 from 7.2.4? we found a problem

Start autocomit trasaction -> update datasets1 in cached updates mode -> start explicit transaction -> update datasets2 in cached mode -> commit explicit transaction -> continue in editation od dataset1

and now all datasets from first autocommit transactions are closed, I see new code in TZAbstractConnection.Commit there was added

Code: Select all

   for i := 0 to FDatasets.Count -1 do
        if Assigned(FDatasets[i]) And
          (TObject(FDatasets[i]) is TZAbstractDataset) and
          TZAbstractDataset(FDatasets[i]).CachedUpdates and
          TZAbstractDataset(FDatasets[i]).UpdatesPending then
            TZAbstractDataset(FDatasets[i]).ApplyUpdates; 
that is a breaking change for us ... we are trying to update to newer zeos to fix some other bug, is it a bug or how should we solve it?

thx
Stan

Edit: reverted code works fine

Code: Select all

procedure TZAbstractConnection.Commit;
var
  ExplicitTran: Boolean;
  i: Integer;
begin
  CheckConnected;
  CheckNonAutoCommitMode;

  ExplicitTran := FExplicitTransactionCounter > 0;
  if FExplicitTransactionCounter < 2 then
  //when 0 then AutoCommit was turned off, when 1 StartTransaction was used
  begin
    ShowSQLHourGlass;
    try
 { TODO -oEgonHugeist : Change this code sequence on 7.3! My automation idea simply is wrong! A commit vs. commitupdate(clear the cache) shouldn't be same! }
      //See: http://zeoslib.sourceforge.net/viewtopic.php?f=38&t=19800
      for i := 0 to FDatasets.Count -1 do
        if (TObject(FDatasets[i]) is TZAbstractDataset) and (not THack_ZAbstractDataset(FDatasets[i]).UpdatesPending) then
          if Assigned(FDatasets[i]) then
            THack_ZAbstractDataset(FDatasets[i]).DisposeCachedUpdates;
      FConnection.Commit;
    finally
      HideSQLHourGlass;
    end;

    FExplicitTransactionCounter := 0;
    if ExplicitTran then
      AutoCommit := True;

    DoCommit;
  end
  else
    Dec(FExplicitTransactionCounter);
end;
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1962
Joined: 17.01.2011, 14:17

Re: Zeos 7.2.10 commit transaction closes all datasets

Post by marsupilami »

Hello Stan,


StTu wrote: 14.06.2021, 09:18 Start autocomit trasaction -> update datasets1 in cached updates mode -> start explicit transaction -> update datasets2 in cached mode -> commit explicit transaction -> continue in editation od dataset1
This workflow shouldn't work as expected with the old version. Usually all your changes to dataset1 should be reverted because of this code in TZAbstractConnection.Commit:

Code: Select all

    for i := 0 to FDatasets.Count -1 do
      if (TObject(FDatasets[i]) is TZAbstractDataset) and (THack_ZAbstractDataset(FDatasets[i]).UpdatesPending) then
        if Assigned(FDatasets[i]) then
          THack_ZAbstractDataset(FDatasets[i]).DisposeCachedUpdates;
The call to DisposeCachedUpdates should have cleared the updates of dataset1 in the old version. If this is what you want, you should do something like

Code: Select all

if dataset1.UpdatesPending then
  dataset1.DisposeCachedUpdates
If you want something different, we need to change the design.

Best regards,

Jan
StTu
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 14.06.2021, 09:09

Re: Zeos 7.2.10 commit transaction closes all datasets

Post by StTu »

Hi Jan,

I'll try to describe my use case, I have two types of listings documents and companies, the user creates a document, one part of that document is a company, user can select the company from the company listing but during selection, the user can edit or create a new company that info has to be persistent and should be saved even if the user does not save the document at the end so I have to do company creation/edit in another transaction, problem is that after committing that transaction changes in the document will be discarded when we switch to last 7.2 version, in the earlier version it was not a problem cause code looks like

if (TObject(FDatasets) is TZAbstractDataset) and (not THack_ZAbstractDataset(FDatasets).UpdatesPending) then
if Assigned(FDatasets) then
THack_ZAbstractDataset(FDatasets).DisposeCachedUpdates;

if I'm reading it right CachedUpdates were disposed only when no pending changes were in the transaction.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1962
Joined: 17.01.2011, 14:17

Re: Zeos 7.2.10 commit transaction closes all datasets

Post by marsupilami »

Hello Stan,

I think, I know what you are doing. I assume that Commit shouldn't touch the cached updates at all and I agree with this. But then - this should not have worked with older versions too. This is from the Dokumentation on UpdatesPending:
TZAbstractRWDataSet.GetUpdatesPending wrote: Checks is there cached updates pending in the buffer.
@return <code>True</code> if there some pending cached updates.
So UpdatesPending is part of the CachedUpdates feature. I wonder why we called DisposeCached updates when UpdatesPending returned false and there were no updates to dispose anyway...
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1962
Joined: 17.01.2011, 14:17

Re: Zeos 7.2.10 commit transaction closes all datasets

Post by marsupilami »

Sooo - I modified Commit again. I think now it does what it is supposed to do: It doesn't interact with Cached Updates at all because there is no reason for it to do so.

Please test the latest SVN revision of Zeos 7.2 and let me know what you think.
StTu
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 14.06.2021, 09:09

Re: Zeos 7.2.10 commit transaction closes all datasets

Post by StTu »

I can't try it today but let it to my college ... will inform you back when we will have some results ... thx
StTu
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 14.06.2021, 09:09

Re: Zeos 7.2.10 commit transaction closes all datasets

Post by StTu »

it seems to be working fine, I'll test more during next week...
Post Reply