#1 2025-12-08 15:59:38

JD
Member
Registered: 2015-08-20
Posts: 127

Service blocked on "prepared statement" error

Hi there everyone,

I have a service based mORMot 2 server in use and sometimes exceptions/errors may occur in the database layer. For instance, this morning, an exception was raised by a PostgreSQL database after a failed INSERT command.

After correcting the error, I tried inserting a record into the table again, but I kept getting an error about the prepared statement not existing:

TSqlDbPostgresLib DescribePrepared failed: 26000 [ERROR: prepared statement "Od" does not exist]

Thankfully, it does not block other users and the other services on the server, but for this particular service, this error remains there until I restart the server, and then everything goes back to normal.

My question is, do I always have to restart the server to get rid of this prepared statement error, or is there something I can change in my server settings or my interface settings that will automatically flush the error after the problem has been corrected in the database layer?

For reference, here are my server settings:

RestServer := TRestServerFullMemory.Create(Model, false);
RestServer.AcquireExecutionMode[execSoaByInterface] := amBackgroundThread;   // ??

ServiceFactoryServer := TServiceFactoryServer(RestServer.ServiceDefine(TRestMethods, [IRoot], TServiceInstanceImplementation.sicShared));
ServiceFactoryServer.SetOptions([], [optErrorOnMissingParam, optExecInPerInterfaceThread, optFreeInPerInterfaceThread]);

Thanks a million,

JD

Last edited by JD (2025-12-08 16:02:08)

Offline

#2 2025-12-09 13:57:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,328
Website

Re: Service blocked on "prepared statement" error

I don't understand what occurred.
Perhaps the connection is in a wrong state after a while?
But the prepared statement names are supposed to be only int64 index as hexadecimal, and "Od" is not this kind of value.
Perhaps there is some memory corruption in your project. Did you run it with full debugging mode?

You could just try to call TSqlDBPostgresConnection.Connect to reset the connection and flush all prepared statements on such error.

Offline

Board footer

Powered by FluxBB