XData database exception

I am making a call to my XData server with the following filter (although that's not the issue - I don't think)

$filter=((Visibility eq 'Everyone') or (Visibility eq 'AnyAdmin') or ((SubmittedBy eq 101) or (OwnedBy eq 101))) and (((Status eq 'New') or (Status eq 'Queued') or (Status eq 'Processing') or (Status eq 'Processed')) or (((Status eq 'Complete') or (Status eq 'Failed')) and (DateCompleted ge '2021-11-17')))&$OrderBy=DateSubmitted

This works most of the time and is called using a timer on a WebCore, but a client testing the system had the following exception

Status code: 500 Error Code: IBNativeException [FireDAC][Phys][FB]Attempt to reclose a closed cursor | fMessage::XData server request error. Uri: [as above]

Any ideas? thanks.

What is Firebird server version (the full version number)? Is this SELECT against a table, a stored procedure or a view? Is the Firebird client library the same version as the server?

1 Like

The Firebird Version is WI-V3.0.5.33220. It is the correct client library.

I guess it is a Select as it is a call to an Entity CRUD point on the XData Server.

Considering this SELECT is against a simple TABLE with NO complex calc fields, and NOT a complex VIEW or STORED PROCEDURE, and there's nothing more going on under the hoods, it can be a FireDAC bug. Also, considering your XData server is correctly using different Firebird connections per thread (request) -- sharing the same connection with different threads (requests) could lead to errors like that.

Does this exception always happens at this client or just sometimes? Is the client testing over a development enviroment or different env?

It's had to understand better what's going on without seeing any code. But I hope you can narrow down the problem.

Best regards,

1 Like

Also, double check your XData server is using the correct Firebird client library (same version as your Firebird server).

Regards,

1 Like

yes, same version

A Google search on this error indicates an issue with Firebird, and sometimes a mismatch between client and server version.
As @Farias_Anderson said, it looks like an issue with either FireDAC or Firebird. Does this error always happen when you execute such query?

1 Like

The only possible issue in XData server would be if by any chance it was implemented to use the same connection for all (simultaneous) requests. Each thread must have it's own connection or Firebird won't behave correctly.

No. The query usually is fine. I did have it once (I think) on my development machine, but not sure.

This should be ok as it is a standard set up XData server with Aurelius Entities.

1 Like

Can you trace it (turn on Firebird trace monitor to get more info)? Also, are there any more info in Firebird.log? I've never seen this error with Firebird except when using the same connection on a multi-threaded system.

You can also update your Firebird server (and client) to last release 3.0.8 althougt I find it unlikely to be a Firebird 3 issue.

Are you using Local or TCP protocol to connect to the database?

Regards,

1 Like

It's tricky as it isn't something we can just recreate at will. I'll need to set aside some time to have a serious look.

2 Likes

This has happened again, very strange. Checking the logs, but we have a MadExcept report:

exception class    : EIBNativeException
exception message  : [FireDAC][Phys][FB]Attempt to reclose a closed cursor.

main thread ($1864):
010628d9 +0a9 GAShopServer.exe FireDAC.Phys.IBWrapper          2603 +10 TIBError.Check
0106122d +03d GAShopServer.exe FireDAC.Phys.IBWrapper          2241  +5 TIBObject.Check
01070587 +0b7 GAShopServer.exe FireDAC.Phys.IBWrapper          6596 +11 TIBStatement.Unprepare
0107ae2b +01b GAShopServer.exe FireDAC.Phys.IBBase             2935  +3 TFDPhysIBCommandBase.InternalUnprepare
00fb80ab +17b GAShopServer.exe FireDAC.Phys                    6949 +27 TFDPhysCommand.Unprepare
00fb68a5 +035 GAShopServer.exe FireDAC.Phys                    6647  +5 TFDPhysCommand.Disconnect
00fa97d6 +046 GAShopServer.exe FireDAC.Phys                    3174  +5 TFDPhysConnection.DisconnectCommands
00fab3c1 +071 GAShopServer.exe FireDAC.Phys                    3575 +15 TFDPhysConnection.Close
0101016b +11b GAShopServer.exe FireDAC.Comp.Client             4253 +16 TFDCustomConnection.DoDisconnect
008e5c26 +0c6 GAShopServer.exe Data.DB                         3553 +18 TCustomConnection.SetConnected
0100fa31 +031 GAShopServer.exe FireDAC.Comp.Client             4181  +4 TFDCustomConnection.SetConnected
008e5b50 +010 GAShopServer.exe Data.DB                         3531  +1 TCustomConnection.Close
0100d367 +027 GAShopServer.exe FireDAC.Comp.Client             3591  +2 TFDCustomConnection.Destroy
0040edf5 +015 GAShopServer.exe System                         17933  +5 TObject.Free
0048d831 +011 GAShopServer.exe System.SysUtils                27028  +3 FreeAndNil
00848ad0 +010 GAShopServer.exe Bcl.Utils                        127  +1 FreeObj
0103833d +03d GAShopServer.exe Aurelius.Drivers.FireDac         134  +3 {Aurelius.Drivers.Base}TDriverConnectionAdapter<FireDAC.Comp.Client.TFDConnection>.Destroy
0041b642 +052 GAShopServer.exe System                         39958  +7 TInterfacedObject._Release
0041982b +02b GAShopServer.exe System                         38782  +6 @IntfClear
004156cf +18f GAShopServer.exe System                         33303 +99 @FinalizeArray
004153d0 +180 GAShopServer.exe System                         33044 +56 @FinalizeRecord
0040ef8a +02a GAShopServer.exe System                         18151  +8 TObject.CleanupInstance
0040ebbb +00b GAShopServer.exe System                         17869  +1 TObject.FreeInstance
005029b1 +021 GAShopServer.exe madExcept                                InterceptClassDestroy
0040edcf +01f GAShopServer.exe System                         17925  +1 TObject.Destroy
0040edf5 +015 GAShopServer.exe System                         17933  +5 TObject.Free
00961694 +014 GAShopServer.exe XData.Aurelius.ConnectionPool    395  +2 {Sparkle.Sys.ObjectPool}TPoolItemFactory<XData.Aurelius.ConnectionPool.TDBConnectionWrapper>.DestroyItem
0096180b +03b GAShopServer.exe XData.Aurelius.ConnectionPool    345  +4 {Sparkle.Sys.ObjectPool}TPoolItemAnonymousFactory<XData.Aurelius.ConnectionPool.TDBConnectionWrapper>.DestroyItem
00960e25 +045 GAShopServer.exe XData.Aurelius.ConnectionPool    228  +3 {Sparkle.Sys.ObjectPool}TObjectPool<XData.Aurelius.ConnectionPool.TDBConnectionWrapper>.DestroyPoolItem
00961288 +068 GAShopServer.exe XData.Aurelius.ConnectionPool    213  +5 {Sparkle.Sys.ObjectPool}TObjectPool<XData.Aurelius.ConnectionPool.TDBConnectionWrapper>.Destroy
0040edf5 +015 GAShopServer.exe System                         17933  +5 TObject.Free
00960685 +025 GAShopServer.exe XData.Aurelius.ConnectionPool    103  +1 TDBConnectionPool.Destroy
0041b642 +052 GAShopServer.exe System                         39958  +7 TInterfacedObject._Release
0041982b +02b GAShopServer.exe System                         38782  +6 @IntfClear
004156cf +18f GAShopServer.exe System                         33303 +99 @FinalizeArray
004153d0 +180 GAShopServer.exe System                         33044 +56 @FinalizeRecord
0040ef8a +02a GAShopServer.exe System                         18151  +8 TObject.CleanupInstance
0040ebbb +00b GAShopServer.exe System                         17869  +1 TObject.FreeInstance
005029b1 +021 GAShopServer.exe madExcept                                InterceptClassDestroy
00e7f20d +08d GAShopServer.exe XData.Server.Module              724  +7 TXDataServerModule.Destroy
0040edf5 +015 GAShopServer.exe System                         17933  +5 TObject.Free
0088b532 +032 GAShopServer.exe Sparkle.HttpServer.Dispatcher     67  +2 THttpServerModuleInfo.Destroy
0040edf5 +015 GAShopServer.exe System                         17933  +5 TObject.Free
0088dcca +03a GAShopServer.exe Sparkle.HttpServer.Dispatcher   7590  +3 {System.Generics.Collections}TObjectList<Sparkle.HttpServer.Dispatcher.THttpServerModuleInfo>.Notify
0088c76c +02c GAShopServer.exe Sparkle.HttpServer.Dispatcher   5049  +1 {System.Generics.Collections}TList<Sparkle.HttpServer.Dispatcher.THttpServerModuleInfo>.InternalNotify
006420e8 +198 GAShopServer.exe System.Generics.Collections     3309 +28 TListHelper.InternalDeleteRange8
00644ea5 +045 GAShopServer.exe System.Generics.Collections     4595  +6 TListHelper.InternalSetCount8
0088cc01 +031 GAShopServer.exe Sparkle.HttpServer.Dispatcher   4871  +1 {System.Generics.Collections}TList<Sparkle.HttpServer.Dispatcher.THttpServerModuleInfo>.Destroy
0088dfb9 +029 GAShopServer.exe Sparkle.HttpServer.Dispatcher   7583  +1 {System.Generics.Collections}TObjectList<Sparkle.HttpServer.Dispatcher.THttpServerModuleInfo>.Destroy
0040edf5 +015 GAShopServer.exe System                         17933  +5 TObject.Free
0088b755 +025 GAShopServer.exe Sparkle.HttpServer.Dispatcher    108  +1 THttpDispatcher.Destroy
0040edf5 +015 GAShopServer.exe System                         17933  +5 TObject.Free
008ac682 +062 GAShopServer.exe Sparkle.HttpSys.Server           136 +10 TCustomHttpSysServer.Destroy
0040edf5 +015 GAShopServer.exe System                         17933  +5 TObject.Free
008ad5c9 +039 GAShopServer.exe Sparkle.Comp.HttpSysDispatcher    46  +3 TSparkleHttpSysDispatcher.Destroy
0040edf5 +015 GAShopServer.exe System                         17933  +5 TObject.Free
0056e83a +09a GAShopServer.exe System.Classes                 16874 +10 TComponent.DestroyComponents
0056e02a +02a GAShopServer.exe System.Classes                 16671  +3 TComponent.Destroy
005717ac +08c GAShopServer.exe System.Classes                 17987  +6 TDataModule.Destroy
0040edf5 +015 GAShopServer.exe System                         17933  +5 TObject.Free
0056e83a +09a GAShopServer.exe System.Classes                 16874 +10 TComponent.DestroyComponents
007e53a4 +044 GAShopServer.exe Vcl.Forms                       2365 +12 DoneApplication
0047cce0 +030 GAShopServer.exe System.SysUtils                 5947  +6 DoExitProc
00411c69 +079 GAShopServer.exe System                         25149 +55 @Halt0
01c3a5f7 +0e7 GAShopServer.exe GAShopServer                      62  +9 initialization
7ff8e719 +00e KERNEL32.DLL                                              BaseThreadInitThunk
7ff8e789 +01b ntdll.dll                                                 RtlUserThreadStart

The call stack just indicates that Aurelius tried to destroy the connection, and the error happened when the underlying TFDConnection is destroyed.

The call stack shows that the error happens when you the dispatcher is destroyed. Are you sure this happens when an endpoint is requested? It doesn't look like it.

It certainly happens on a call via a TXDataWebDataset. Whether that is the first point I'm not sure. Once it has happened then all calls have the same result.

This makes sense from what I see from the error, which looks like happens when dispatcher is destroyed. But I have no clue why it is happening. I'm afraid I will need more information, and/or a way to consistently reproduce it.