Exception in releaseimmediate

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
dcoun
Fresh Boarder
Fresh Boarder
Posts: 10
Joined: 16.09.2022, 08:44

Exception in releaseimmediate

Post by dcoun »

With last commit in 8.0-fixes trunk I seldom get this Exception Error Stack:
Exception: 20221022 07071001 + EXC EListError {Message:"List index out of bounds (4)"} [] at 3f2c98 System.Classes.pas TList.Get (5109) System.Classes.pas TList.Get (5109) System.Classes.pas TList.Get (5109) ZDbcConnection.pas TZAbstractSingleTxnConnection.ReleaseImmediat (2245) ZDbcMySql.pas TZMySQLConnection.ReleaseImmediat (928) ZDbcStatement.pas TZAbstractStatement.ReleaseImmediat (1680) ZDbcStatement.pas TZAbstractPreparedStatement.ReleaseImmediat (3861) ZDbcMySqlStatement.pas TZAbstractMySQLPreparedStatement.ReleaseImmediat (948) ZDbcConnection.pas TZAbstractDbcConnection.ReleaseImmediat (1192) ZDbcConnection.pas TZAbstractSingleTxnConnection.ReleaseImmediat (2245) ZDbcMySql.pas TZMySQLConnection.ReleaseImmediat (928) ZDbcStatement.pas TZAbstractStatement.ReleaseImmediat (1680) ZDbcStatement.pas TZAbstractPreparedStatement.ReleaseImmediat (3861) ZDbcMySqlStatement.pas TZAbstractMySQLPreparedStatement.ReleaseImmediat (948) ZDbcConnection.pas TZAbstractDbcConnection.ReleaseImmediat (1192) ZDbcConnection.pas TZAbstractSingleTxnConnection.ReleaseImmediat (2245) ZDbcMySql.pas TZMySQLConnection.ReleaseImmediat (928) ZDbcStatement.pas TZAbstractStatement.ReleaseImmediat (1680) ZDbcStatement.pas TZAbstractPreparedStatement.ReleaseImmediat (3861) ZDbcMySqlStatement.pas TZAbstractMySQLPreparedStatement.ReleaseImmediat (948) ZDbcConnection.pas TZAbstractDbcConnection.ReleaseImmediat (1192) ZDbcConnection.pas TZAbstractSingleTxnConnection.ReleaseImmediat (2245) ZDbcMySql.pas TZMySQLConnection.ReleaseImmediat (928) ZDbcStatement.pas TZAbstractStatement.ReleaseImmediat (1680) ZDbcStatement.pas TZAbstractPreparedStatement.ReleaseImmediat (3861) ZDbcMySqlStatement.pas TZAbstractMySQLPreparedStatement.ReleaseImmediat (948)

The ZDbcConnection.pas TZAbstractSingleTxnConnection.ReleaseImmediat (2245) si:

Code: Select all

  if (fActiveTransaction <> nil) and (fActiveTransaction.QueryInterface(IImmediatelyReleasable, imm) = S_OK) and (imm <> Sender) then begin
    imm.ReleaseImmediat(Sender, AError);
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Exception in releaseimmediate

Post by marsupilami »

Hello,

I looked into this. The problem is that this line doesn't do anything with a TList - at least as far as I can see. Could you please check if Optimizations are turned off in the project settings? Sometimes this gives better stack traces.

With best regards,

Jan
dcoun
Fresh Boarder
Fresh Boarder
Posts: 10
Joined: 16.09.2022, 08:44

Re: Exception in releaseimmediate

Post by dcoun »

I found the reason why this exception happens. If mariadb servers restarts or disconnects, it results to this error
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Exception in releaseimmediate

Post by marsupilami »

Yes - ReleaseImmediat is part of the handling when connections are lost. But usually we shouldn't have this problem :(
dcoun
Fresh Boarder
Fresh Boarder
Posts: 10
Joined: 16.09.2022, 08:44

Re: Exception in releaseimmediate

Post by dcoun »

I will try to debug it a bit. Do you have something to propose for that?
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Exception in releaseimmediate

Post by marsupilami »

My first suggestion is disable optimizations in Delphi. This helps keeping the stack trace correct. Maybe it is worth setting up a separate application for tests and do something like this:

- Connect to MariaDB/MySQL from Zeos
- Stop MariaDB/MySQL (or just pull the network cable)
- Try to do something in Zeos

Usually this should lead to an exception telling you that the connection was lost.
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 797
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Exception in releaseimmediate

Post by aehimself »

Maybe you don't need to interrupt the network. Check if killing the session is sufficient, this would make testing a lot more easy:

https://dataedo.com/kb/query/mysql/kill-session

MySQL's current implementation of .AbortOperation is similar:

Code: Select all

function TZMySQLConnection.AbortOperation: Integer;
Var
 killquery: SQLString;
 izc: IZConnection;
Begin
  { EH untested, just prepared
  if Assigned(FPlainDriver.mariadb_cancel) then begin
    Result := FPlainDriver.mariadb_cancel(FHandle);
    FPlainDriver.mariadb_reconnect(FHandle)
  end else }begin
    // https://dev.mysql.com/doc/refman/5.7/en/mysql-kill.html
    killquery := 'KILL QUERY ' + IntToStr(FPlainDriver.mysql_thread_id(FHandle));
    izc := DriverManager.GetConnection(GetURL);
    Result := izc.CreateStatement.ExecuteUpdate(killquery);
  end;
End;
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
Post Reply