You are not logged in.
I'm using mORMot with PostgreSQL, and I suddenly started getting this error:
Project Vi.exe raised exception class ESqlDBPostgres with message:
TSqlDBPostgresLib Exec failed:
[lost synchronization with server: got message type "lost synchronization with server: got message type"]After this error occurs, the application can no longer connect to the database unless restarted.
Here is how I initialize the connection:
Model := CreateViModel;
DBProps := TSqlDBPostgresConnectionProperties.Create(
Host, DBName, DBUser, DBPass
);
DBProps.UseCache := False;
DBProps.ReconnectAfterConnectionError := True;
VirtualTableExternalRegister(Model, TOrmTenant, DBProps);
...Additional details:
The issue seems to happen when rapidly switching between menus in the client (HTMX-based UI).
It looks like multiple concurrent requests may be involved.
After the error, even reconnection does not recover properly.
Questions:
Could this be related to connection reuse or thread safety in mORMot?
Should I be using a connection pool or per-thread connection instead?
Is there a known issue with PostgreSQL driver synchronization in such scenarios?
Any guidance or similar experiences would be appreciated.
Last edited by Kabiri (2026-04-14 07:24:36)
Offline
If I understand correctly https://www.postgresql.org/message-id/1 … nabble.com
it sounds like the server closed the connection due to too big/slow request.
Look at the request itself, and the full error message.
It may be more tied to the request and server itself that with mORMot.
There is a per-thread connection pool in mORMot.
So nothing is to be configured here.
Just don't create too many threads in your code.
Offline
I was using PostgreSQL 17.6-2. I’ll upgrade to PostgreSQL 18.3-2 and test it.
Maybe the issue was related to this: https://www.postgresql.org/message-id/2 … .pgh.pa.us
Offline
@ab
I updated it and everything was working fine.
After some time—without rapidly switching between menus and without any errors—everything stopped working.
The application reaches this line but never returns from it:
u := TOrmUser.Create;
try
if not Self.Server.Orm.Retrieve('Email=?',[],[Email],u) thenOffline
Isn’t there any solution?
It’s really frustrating. Right now, even during testing with no users, it keeps getting stuck and I have to restart the service. What should I do when there are many users?
Offline
With Zeos we never had such an issue. So it seems to be mormot direct access unit problem.
Offline
Could you try with the Zeos client and see if it is a mormot direct access unit problem?
I am AFK those days, so I can't test anything.
Ok, thanks. I’ll check it and let you know.
Offline
The `Zeos.inc` file used in `mormot.db.sql.zeos` cannot be found.
Offline
The `Zeos.inc` file used in `mormot.db.sql.zeos` cannot be found.
Have you installed 'Zeos' before using it as a DB connection? 'Zeos.inc' is in the 'src' folder of the 'Zeos' installation.
Offline
Have you installed 'Zeos' before using it as a DB connection?
No, I haven’t installed it. I thought it didn’t require installation. I’ll install it now.
Offline
After several hours of working with the application, and repeatedly opening and closing menus, the following error suddenly appeared:
Project Vi.exe raised exception class EZSQLException with message
'SQL Error: insufficient data in "T" message
Code: 7
SQL: select ID,Name,Slug,Plan,OwnerID,IsActive,MaxMembers,CreatedAt
from public.Tenant where ID=?'.After that, the application no longer responds to any requests.
This is how I established the connection:
DBProps := TSqlDBZeosConnectionProperties.Create('zdbc:postgresql://' + Host, DBName, DBUser, DBPass);Offline
It happened again. This time the error was:
Project Vi.exe raised exception class EZSQLException with message
'SQL Error: message contents do not agree with length in message type "T"
server sent data ("D" message) without prior row description ("T" message)
Code: 7
SQL: select ID,TenantID,Email,FullName,PasswordHash,Role,AvatarUrl,CreatedAt
from public.User where ID=?'.After that, the application raised the following exception:
Project Vi.exe raised exception class $C0000005 with message
'c0000005 ACCESS_VIOLATION'.The client is using HTMX.
Offline
Wether Zeos nor mORMot2 error.
Something in your own project went wrong.
I would guess libpq is out of sync with server because of using it in a multi-threaded application in a absolutely wrong way.
Offline
...in message type "T" server sent data "D" message without prior row description ("T" message)
the message itself really give hint about what @daniel is suggesting: wrong multi-thread usage.
you really need to give more information and eliminate causes. First answer @ab and tell us:
- version of libpq in use
then,
- check if is zeos-specific by running the same sql:
1. psql,
2. pgAdmin,
3. a tiny test executable using only one connection and one thread
- eliminate the dll ambiguity:
1. copy the chosen libpq.dll to the EXE folder (keep only the dependent DLLs required by that build)
2. temporarily rename any other libpq.dll reachable through PATH
But again, it seem to be a thread issue:
Same connection used concurrently from multiple threads
If two threads share one PostgreSQL connection or one query object and interleave reads/writes on the same socket, the message stream becomes corrupted from the client’s perspective. The symptom often looks exactly like “unexpected message type while idle” or “DataRow without prior RowDescription,” because packets are being attributed to the wrong command.
Offline
Are you sure the libpq library is in the same version than the server?
Yes.
After installing the new version, I copied it from
C:\Program Files\PostgreSQL\18\pgAdmin 4\runtime
and placed it next to my application.
Offline
@flydev @danielkuettner
I removed the DLL files from next to the application and the error appeared, so it seems it is using those DLLs. Maybe it’s related.
I registered the services like this:
Server.ServiceDefine(TViAuthService, [IViAuthService], sicShared);Would `sicPerThread` help?
In my application I don’t have multiple threads, but the client can send asynchronous requests. I assumed that on the server side it would be handled internally.
Last edited by Kabiri (2026-04-18 11:13:52)
Offline
Now you are on the right way.
Client requests are handled in threads on service side. Every thread needs its own (separate) connection to postgres to work properly.
Or you use only one connection to db and synchronize threads with critical sections.
Or you handle all db access in one thread (e.g. MainThread). There are options on mORMot for that.
You have options and all depends on what you want.
Offline
I changed all services from:
Server.ServiceDefine(TViAuthService, [IViAuthService], sicShared);to
Server.ServiceDefine(TViAuthService, [IViAuthService], sicPerThread);but the error still occurs.
Once again, the error happens inside `libpq.dll`.
Offline
sicShared/sicPerThread has no effect to the actual threading, only to the TViAuthService class instance executed on the server.
Only sicInMainThread or sicInBackgroundThread could force execution in a single thread.
But the mormot postgresl connector maintain a per-thread connection, unless you disable this, so there should be no problem with concurrent access. And even more, the ORM.
How to you access the SQL? Only using the ORM?
We need a minimal reproducible example to investigate further.
It seems that you are the first to report this issue.
Offline
I only used the ORM.
I should create a smaller sample project, and if the same issue still occurs, I will send it to you.
Offline
@ab
I created a small program and sent a large number of concurrent requests, and there were no errors.
This program is different from the main application.
In the main application, I wrote a function for `Server.OnBeforeURI`, and inside that function I have the following code:
var AuthService := TViAuthService.Create;
try
CurrentTenantID := TenantID;
CurrentUserID := UserID;
var ORM := Ctxt.Server.Orm;
AuthService.IsValidLogin(ORM, CurrentTenantID, CurrentUserID, CurrentUserRole);
finally
AuthService.Free;
end;Could this be the reason for these errors?
----Edit----
I removed this code as well, but it still happened.
Last edited by Kabiri (2026-04-22 19:40:43)
Offline
So it is likely that the issue does not come directly from mORMot, but from some pointer issues in the code.
Did you try to run with the heap manager in FullDebugMode to check for heap corruption?
Offline
What type of http server you use (TRestHttpServerUse)? I have a problem with useHttpAsync and FirebirdSql connection in interface service! Switching to useHttpSocket, problem disappear, different threading model. Problem was bug in my code, after bug resolve, both useHttpAsync and useHttpSocket are OK.
Offline
@ab I didn’t use pointers in my code.
Everything is wrapped in try/finally blocks.
I have 21 models, 87 endpoints, and 10 services.
I used interfaces.
Also, I created the HTTP server like this:
Http := TRestHttpServer.Create(Port, [Server], '+', useHttpSocket);And the server is created as:
Server := TRestServerDB.Create(Model, ':memory:', False);@ttomas : What exactly was your issue?
Offline
Just sayin, without any code to read and/or reproducible sample it's really hard to help.. if you have any ai tool at hand then just ask it to extract a sample, and even better, install a debugging skill on it and throw it on your codebase.
Offline
@ttomas : What exactly was your issue?
I don't use orm part and need to close db connection after interface use TSqlDBConnectionProperties.ThreadSafeConnection.Disconnect, without lock :-). I need my service to not use any db connection if users are out.
I just notice on slow req/rate useHttpSocket round robin all working threads, create connections on all threads. But async server create only one connection on first working thread. Http working thread=DB pool thread connection.
Offline
I guess your code is wrong (e.g. in Server.OnBeforeURI).
It's definitely a threading issue (when you look at the postgres error). Such issues wouldn't exist, if you would make in right (there are examples for that).
The Interfaced Services should be created only once at startup with ServiceDefine. After that you work in your methods of that class (TViAuthService) using ORM or Props.Execute...
All the other stuff does the little mORMot in background for you.
A manuell creation on Server.OnBeforeURI is not wanted by the creator of the little mORMot. Am I wrong @ab?
Offline
@danielkuettner is correct of course: you need to let the service instances be created by the server, using the Resolve() method.
But I suspect the TViAuthService class is in fact not a mORMot service class, more like a "repository pattern" local class.
Offline
Hi ab,
Server.ServiceDefine(TViAuthService, [IViAuthService], sicShared);
and later than I read
var AuthService := TViAuthService.Create;...
That's why I came on this.
But you are right, it's just a wild guess.
Offline
Just sayin, without any code to read and/or reproducible sample it's really hard to help.. if you have any ai tool at hand then just ask it to extract a sample, and even better, install a debugging skill on it and throw it on your codebase.
I created a sample code, but it didn’t produce any errors.
I perform JWT validation in Server.OnBeforeURI.
Offline
Does this connection method help?
{$ifdef DBZeos}
DBProps := TSqlDBZeosConnectionProperties.Create('zdbc:postgresql://'+Host,
DBName, DBUser, DBPass);
{$else}
DBProps := TSqlDBPostgresConnectionProperties.Create(Host, DBName, DBUser, DBPass);
{$endif}
DBProps.UseCache := False;
DBProps.ReconnectAfterConnectionError := True;
{$ifdef DBZeos}
DBProps.ThreadingMode := tmMainConnection;
{$else}
(DBProps as TSQLDBConnectionPropertiesThreadSafe).ThreadingMode := tmMainConnection;
{$endif}Last edited by Kabiri (2026-04-24 10:44:21)
Offline
Why you use tmMainConnection? By default you have 32(you can change on creation of http server) http working threads and only one db connection (no db pool) in main thread. This working threads must wait from main thread to get/set data from single mainthread db connection.
If you use tmThreadPool, then all 32 working thread will create db connection and you will not have waiting/switch between threads for db connection. Yes some databases have problem with threading, but posgresql as I know don't have a problem.
Last edited by ttomas (Yesterday 18:25:16)
Offline
As far as I understood, this happens because two or more threads are using the same database connection at the same time.
I thought that with this approach there would be only one thread for database access.
However, the error does not occur immediately after startup.
Sometimes it happens after 5 minutes, sometimes after 30 minutes.
I tried using tmMainConnection. This time it does not show an error, but the server suddenly freezes and after a short time it gets terminated.
Log:
20260425 18025759 ! http mormot.rest.http.server.TRestHttpServer(0279a5691120) {THttpServer(0279a574f6a0):{ProcessName:"root",ServerName:"mORMot2 (Win)",ApiVersion:"WinSock 2.0.514",Router:{TUriRouter(0279a57b5120):{Gets:1}},SockPort:"8080",ServerKeepAliveTimeOut:30000,ThreadPool:{TSynThreadPoolTHttpServer(0279a52202f0):{WorkThreadCount:32,RunningThreads:32}}}} initialized for root
20260425 18025759 ! - 07.630.231
20260425 18025853 C info SetThreadName 35 2d40 11584=conn-1
20260425 18025853 C trace mormot.rest.sqlite3.TRestServerDB(0279a51e6780) BeginCurrentThread(THttpServerResp) root=root ThreadID=11584 'conn-1' ThreadCount=2
20260425 18025915 D info SetThreadName 36 049c 1180=conn-2
20260425 18025915 D trace mormot.rest.sqlite3.TRestServerDB(0279a51e6780) BeginCurrentThread(THttpServerResp) root=root ThreadID=1180 'conn-2' ThreadCount=3
20260425 18025915 C + mormot.rest.sqlite3.TRestServerDB(0279a51e6780) Uri/1 POST ViTaskService.ViewTask in=14
20260425 18025915 D + mormot.rest.sqlite3.TRestServerDB(0279a51e6780) Uri/2 POST ViTaskService.GetDetail in=14
20260425 18025915 C call mormot.rest.sqlite3.TRestServerDB(0279a51e6780) ViTaskService.ViewTask len=14 {"TaskID":"2"}
20260425 18025915 D call mormot.rest.sqlite3.TRestServerDB(0279a51e6780) ViTaskService.GetDetail len=14 {"TaskID":"2"}
20260425 18025915 C debug mormot.soa.server.TServiceFactoryServer(0279a571d5c0) TServiceFactoryServer.RetrieveInstance: new IViTaskService(2721485746416) sicPerThread instance (id=11584) count=1
20260425 18025915 D debug mormot.soa.server.TServiceFactoryServer(0279a571d5c0) TServiceFactoryServer.RetrieveInstance: new IViTaskService(2721485746496) sicPerThread instance (id=1180) count=2
20260425 18025915 C DB mormot.db.sql.postgres.TSqlDBPostgresStatement(0279a571e4c0) Prepare t=3us q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where ID=?
20260425 18025915 D DB mormot.db.sql.postgres.TSqlDBPostgresStatement(0279a571e640) Prepare t=5us q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where ID=?
20260425 18030847 E info SetThreadName 37 1f80 8064=conn-3
20260425 18030847 E trace mormot.rest.sqlite3.TRestServerDB(0279a51e6780) BeginCurrentThread(THttpServerResp) root=root ThreadID=8064 'conn-3' ThreadCount=4
20260425 18030920 F info SetThreadName 38 70 112=conn-4
20260425 18030920 F trace mormot.rest.sqlite3.TRestServerDB(0279a51e6780) BeginCurrentThread(THttpServerResp) root=root ThreadID=112 'conn-4' ThreadCount=5
20260425 18030921 E + mormot.rest.sqlite3.TRestServerDB(0279a51e6780) Uri/3 POST ViTaskService.ViewTask in=14
20260425 18030921 F + mormot.rest.sqlite3.TRestServerDB(0279a51e6780) Uri/4 POST ViTaskService.GetDetail in=14
20260425 18030921 E call mormot.rest.sqlite3.TRestServerDB(0279a51e6780) ViTaskService.ViewTask len=14 {"TaskID":"2"}
20260425 18030921 E debug mormot.soa.server.TServiceFactoryServer(0279a571d5c0) TServiceFactoryServer.RetrieveInstance: new IViTaskService(2721485746736) sicPerThread instance (id=8064) count=3
20260425 18030921 E DB mormot.db.sql.postgres.TSqlDBPostgresStatement(0279a571e7c0) Prepare t=4us q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where ID=?
20260425 18030921 F call mormot.rest.sqlite3.TRestServerDB(0279a51e6780) ViTaskService.GetDetail len=14 {"TaskID":"2"}
20260425 18030921 F debug mormot.soa.server.TServiceFactoryServer(0279a571d5c0) TServiceFactoryServer.RetrieveInstance: new IViTaskService(2721485746896) sicPerThread instance (id=112) count=4
20260425 18030921 F DB mormot.db.sql.postgres.TSqlDBPostgresStatement(0279a571e940) Prepare t=4us q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where ID=?
20260425 18033937 G info SetThreadName 39 52a8 21160=conn-5
20260425 18033937 G trace mormot.rest.sqlite3.TRestServerDB(0279a51e6780) BeginCurrentThread(THttpServerResp) root=root ThreadID=21160 'conn-5' ThreadCount=6
20260425 18033937 G + mormot.rest.sqlite3.TRestServerDB(0279a51e6780) Uri/5 GET ViProjectService.GetList in=0
20260425 18034019 H info SetThreadName 40 174c 5964=conn-6
20260425 18034019 H trace mormot.rest.sqlite3.TRestServerDB(0279a51e6780) BeginCurrentThread(THttpServerResp) root=root ThreadID=5964 'conn-6' ThreadCount=7
20260425 18034019 G debug mormot.soa.server.TServiceFactoryServer(0279a571d440) TServiceFactoryServer.RetrieveInstance: new IViProjectService(2721485747216) sicPerThread instance (id=21160) count=1
20260425 18034020 H + mormot.rest.sqlite3.TRestServerDB(0279a51e6780) Uri/6 POST ViTeamService.GetList in=2
20260425 18034020 G DB mormot.db.sql.postgres.TSqlDBPostgresStatement(0279a571eac0) Prepare t=7us q=select ID,TenantID,Name,Description,Status,CreatedBy,CreatedAt from public.Project where TenantID=? and Status=?
20260425 18034020 H debug mormot.soa.server.TServiceFactoryServer(0279a571dbc0) TServiceFactoryServer.RetrieveInstance: new IViTeamService(2721485747376) sicPerThread instance (id=5964) count=1
20260425 18034021 H DB mormot.db.sql.postgres.TSqlDBPostgresStatement(0279a571ec40) Prepare t=3us q=select ID,TenantID,ProjectID,Name,ManagerID,WorkflowID,CreatedAt from public.Team where TenantID=?
20260425 18035351 ! + mormot.rest.http.server.TRestHttpServer(0279a5691120) Destroy
20260425 18035352 ! http mormot.rest.http.server.TRestHttpServer(0279a5691120) {THttpServer(0279a574f6a0):{ProcessName:"root",ServerName:"mORMot2 (Win)",ApiVersion:"WinSock 2.0.514",Router:{TUriRouter(0279a57b5120):{Gets:3}},SockPort:"8080",ServerKeepAliveTimeOut:30000,StatHeaderProcessed:6,ServerConnectionActive:6,ServerConnectionCount:6,ThreadPool:{TSynThreadPoolTHttpServer(0279a52202f0):{WorkThreadCount:32,RunningThreads:32}}}} finalized for 1 server
20260425 18035352 ! + mormot.rest.http.server.TRestHttpServer(0279a5691120) Shutdown(true)
20260425 18035352 ! - 00.000.911
20260425 18035352 A - 55.933.921
20260425 18035352 A trace mormot.rest.sqlite3.TRestServerDB(0279a51e6780) EndCurrentThread(THttpServer) ThreadID=290c 'root' ThreadCount=6
20260425 18041356 ! - 20.076.705
20260425 18041356 ! + mormot.rest.sqlite3.TRestServerDB(0279a51e6780) Shutdown() root CurrentRequestCount=6
20260425 18044357 ! - 30.016.140
20260425 18044358 ! info mormot.rest.sqlite3.TRestServerDB(0279a51e6780) TRest.Destroy root
20260425 18044358 ! trace mormot.rest.sqlite3.TRestServerDB(0279a51e6780) TServiceFactoryServer.Destroy: finalize 1 IViProjectService sicPerThread
20260425 18044358 ! trace mormot.rest.sqlite3.TRestServerDB(0279a51e6780) TServiceFactoryServer.Destroy: finalize 4 IViTaskService sicPerThread
20260425 18044358 ! trace mormot.rest.sqlite3.TRestServerDB(0279a51e6780) TServiceFactoryServer.Destroy: finalize 1 IViTeamService sicPerThread
20260425 18044359 ! + mormot.orm.sqlite3.TRestOrmServerDB(0279a51ef840) Destroy root
20260425 18044359 ! + mormot.db.raw.sqlite3.TSqlDatabase(0279a529b760) Destroy
20260425 18044359 ! + mormot.db.raw.sqlite3.TSqlDatabase(0279a529b760) DBClose
20260425 18044359 ! DB mormot.db.raw.sqlite3.TSqlDatabase(0279a529b760) closing [:memory:] 4 KB
20260425 18044359 ! - 00.003.600
20260425 18044359 ! - 00.006.929
20260425 18044359 ! - 00.010.780Now I have removed tmMainConnection, but still no error has appeared yet, so I haven’t included a new log.
Offline
Well, now I’m getting this error:
Project Vi.exe raised exception class ESqlDBPostgres with message
“TSqlDBPostgresLib Exec failed: [message contents do not agree with length in message type "T"
server sent data ("D" message) without prior row description ("T" message)]”.It happened.
TSqlDBPostgresStatement object 016914ac4940 was previously used by conn-2 (ThreadID=29bc) across multiple queries (lines 201–232).
20260425 19471004 D DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Prepare t=118.73ms q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where ID=?
20260425 19471004 C SQL mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac47c0) Execute t=119.72ms c= r=1 q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where ID=1
20260425 19471004 C DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac47c0) Prepare t=4us q=select ID,TenantID,TaskID,UserID,InternalStatus,ViewedAt,UpdatedAt from public.TaskUserStatus where TaskID=? and UserID=? and TenantID=? limit 1
20260425 19471004 D SQL mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Execute t=122.58ms c= r=1 q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where ID=1
20260425 19471004 C SQL mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac47c0) Execute t=2.50ms c= r=1 q=select ID,TenantID,TaskID,UserID,InternalStatus,ViewedAt,UpdatedAt from public.TaskUserStatus where TaskID=1 and UserID=4 and TenantID=1 limit 1
20260425 19471004 D DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Prepare t=3us q=select ID,TenantID,Email,FullName,PasswordHash,Role,AvatarUrl,CreatedAt from public.User where ID=?
20260425 19471004 C srvr mormot.rest.server.TRestServerRoutingRest(016914ac17a0) Interface POST ViTaskService.ViewTask=200 out=82 in 130.41ms
20260425 19471005 C ret mormot.rest.sqlite3.TRestServerDB(016914586780) Interface len=82 {"result":[{"ErrorCode":0,"DataCount":1,"Data":[{"Successful":True}]}],"id":14208}
20260425 19471005 C - 00.132.847
20260425 19471005 D SQL mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Execute t=4.80ms c= r=1 q=select ID,TenantID,Email,FullName,PasswordHash,Role,AvatarUrl,CreatedAt from public.User where ID=1
20260425 19471005 D DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Prepare t=3us q=select ID,UserID,Body,CreatedAt from public.Comment where TenantID=? and TaskID=? order by CreatedAt
20260425 19471005 D SQL mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Execute t=2.07ms c= r=0 q=select ID,UserID,Body,CreatedAt from public.Comment where TenantID=1 and TaskID=1 order by CreatedAt
20260425 19471005 D DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Prepare t=2us q=select ID,UserID,Action,OldVal,NewVal,Note,CreatedAt from public.ActivityLog where TenantID=? and TaskID=? order by CreatedAt desc
20260425 19471006 D SQL mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Execute t=2.07ms c= r=11 q=select ID,UserID,Action,OldVal,NewVal,Note,CreatedAt from public.ActivityLog where TenantID=1 and TaskID=1 order by CreatedAt desc
20260425 19471006 D DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Prepare t=1us q=select ID,DependsOnTaskID,DepType from public.TaskDependency where TenantID=? and TaskID=?
20260425 19471006 D SQL mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Execute t=2.03ms c= r=0 q=select ID,DependsOnTaskID,DepType from public.TaskDependency where TenantID=1 and TaskID=1
20260425 19471006 D DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Prepare t=2us q=select ID,Title,Status,State,Priority,AssigneeID from public.Task where TenantID=? and ParentTaskID=?
20260425 19471006 D SQL mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Execute t=595us c= r=2 q=select ID,Title,Status,State,Priority,AssigneeID from public.Task where TenantID=1 and ParentTaskID=1
20260425 19471006 D DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Prepare t=1us q=select InternalStatus,ViewedAt from public.TaskUserStatus where TenantID=? and TaskID=? and UserID=?
20260425 19471006 D SQL mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Execute t=2.02ms c= r=1 q=select InternalStatus,ViewedAt from public.TaskUserStatus where TenantID=1 and TaskID=1 and UserID=4
20260425 19471006 D srvr mormot.rest.server.TRestServerRoutingRest(016914ac19b0) Interface POST ViTaskService.GetDetail=200 out=1783 in 160.61ms
20260425 19471006 D ret mormot.rest.sqlite3.TRestServerDB(016914586780) Interface len=1783 {"result":[{"ErrorCode":0,"DataCount":1,"Data":{"id":1,"title":"اضافه کردن بخش وظایف","description":"اضافه کردن و تکمیل بخش وظایف به وب سایت","priority":0,"status":0,"state":0,"assigneeId":1,"assigneeName":"hamid","currentStepId":3,"needsApproval":0,"isApproved":1,"parentTaskId":0,"startDate":0,"dueDate":135977631744,"finishedAt":0,"myStatus":[{"internalstatus":1,"viewedat":135978202523}] ,"comments":[],"log":[{"id":13,"userid":4,"action":1,"oldval":4,"newval":1,"note":null,"createdat":135978367808}, {"id":12,"userid":4,"action":7,"oldval":4,"newval":3,"note":null,"createdat":135978367808}, {"id":10,"userid":1,"action":4,"oldval":3,"newval":4,"note":"jjjj","createdat":135978202374}, {"id":11,"userid":1,"action":1,"oldval":1,"newval":4,"note":null,"createdat":135978202374}, {"id":7,"userid":1,"action":6,"oldval":0,"newval":0,"note":"","createdat":135977836969}, {"id":8,"userid":1,"action":1,"oldval":3,"newval":1,"note":"","createdat":135977836969}, {"id":6,"userid":3,"action":4,"oldval":2,"newval":3,"note":"ارحا از Developer","createdat":135977836816}, {"id":5,"userid":2,"action":1,"oldval":2,"newval":3,"note":"","createdat":135977836745}, {"id":4,"userid":2,"action":6,"oldval":0,"newval":0,"note":"تایید","createdat":135977836745}, {"id":3,"userid":2,"action":4,"oldval":1,"newval":2,"note":"ارجا از منیجر","createdat":135977836662}, {"id":1,"userid":1,"action":0,"oldval":0,"newval":1,"note":"","createdat":135977713000}] ,"dependencies":[],"subTasks":[{"id":2,"title":"اضافه کردن زیر وظیفه","status":0,"state":0,"priority":0,"assigneeid":0}, {"id":3,"title":"اضافه کردن چند زبانه","status":0,"state":0,"priority":0,"assigneeid":0}] }}],"id":10684}
20260425 19471006 D - 00.162.312
20260425 19471007 D + mormot.rest.sqlite3.TRestServerDB(016914586780) Uri/2 POST ViTaskService.GetById in=14
20260425 19471007 D call mormot.rest.sqlite3.TRestServerDB(016914586780) ViTaskService.GetById len=14 {"TaskID":"1"}
20260425 19471007 D DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Prepare t=3us q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where ID=?
20260425 19471007 D SQL mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Execute t=734us c= r=1 q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where ID=1
20260425 19471654 D DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Prepare t=4us q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where TenantID=? and ID=?
20260425 19471654 D SQL mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Execute t=896us c= r=1 q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where TenantID=1 and ID=1
20260425 19471654 D srvr mormot.rest.server.TRestServerRoutingRest(016914ac19b0) Interface POST ViTaskService.GetById=200 out=528 in 6.75s
20260425 19471655 D ret mormot.rest.sqlite3.TRestServerDB(016914586780) Interface len=528 {"result":[{"ErrorCode":0,"DataCount":1,"Data":[{"id":1,"tenantid":1,"projectid":1,"teamid":1,"workflowid":1,"currentstepid":3,"parenttaskid":0,"title":"اضافه کردن بخش وظایف","description":"اضافه کردن و تکمیل بخش وظایف به وب سایت","priority":0,"status":0,"state":0,"needsapproval":0,"isapproved":1,"approvedby":1,"assigneeid":1,"createdby":1,"startdate":0,"duedate":135977631744,"finishedat":0,"createdat":135977713000,"updatedat":135978367808,"progresspercent":0}] }],"id":10684}
20260425 19471655 D - 06.760.446After conn-2 called EndCurrentThread, the same statement object was reused by conn-4 (ThreadID=23376) — visible at line 273.
20260425 19474623 D DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Prepare t=8us q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where ID=?When conn-4 (ThreadID=23376) and conn-5 (ThreadID=24728) both called Prepare simultaneously on statement objects 016914ac4940 and 016914ac4ac0 respectively, a PostgreSQL protocol-level exception was raised:
message contents do not agree with length in message type "T" / server sent data ("D" message) without prior row description ("T" message)
line 309-323
20260425 19481661 C trace mormot.rest.sqlite3.TRestServerDB(016914586780) EndCurrentThread(THttpServerResp) ThreadID=3780 'conn-1' ThreadCount=3
20260425 19481662 D trace mormot.rest.sqlite3.TRestServerDB(016914586780) EndCurrentThread(THttpServerResp) ThreadID=29bc 'conn-2' ThreadCount=2
20260425 19481705 E trace mormot.rest.sqlite3.TRestServerDB(016914586780) EndCurrentThread(THttpServerResp) ThreadID=3c60 'conn-3' ThreadCount=1
20260425 19485053 E info SetThreadName 37 5b50 23376=conn-4
20260425 19485053 E trace mormot.rest.sqlite3.TRestServerDB(016914586780) BeginCurrentThread(THttpServerResp) root=root ThreadID=23376 'conn-4' ThreadCount=2
20260425 19485111 E trace mormot.rest.sqlite3.TRestServerDB(016914586780) BeginCurrentThread(THttpServerResp) root=root ThreadID=24728 'conn-5' ThreadCount=3
20260425 19485111 E + mormot.rest.sqlite3.TRestServerDB(016914586780) Uri/4 POST ViTaskService.ViewTask in=14
20260425 19485111 E + mormot.rest.sqlite3.TRestServerDB(016914586780) Uri/5 POST ViTaskService.GetDetail in=14
20260425 19485111 E call mormot.rest.sqlite3.TRestServerDB(016914586780) ViTaskService.ViewTask len=14 {"TaskID":"1"}
20260425 19485111 E call mormot.rest.sqlite3.TRestServerDB(016914586780) ViTaskService.GetDetail len=14 {"TaskID":"1"}
20260425 19485111 E debug mormot.soa.server.TServiceFactoryServer(016914ac38c0) TServiceFactoryServer.RetrieveInstance: new IViTaskService(1550825746912) sicPerThread instance (id=24728) count=2
20260425 19485111 E debug mormot.soa.server.TServiceFactoryServer(016914ac38c0) TServiceFactoryServer.RetrieveInstance: new IViTaskService(1550825746592) sicPerThread instance (id=23376) count=1
20260425 19485112 E DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4ac0) Prepare t=5us q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where ID=?
20260425 19485112 E DB mormot.db.sql.postgres.TSqlDBPostgresStatement(016914ac4940) Prepare t=3us q=select ID,TenantID,ProjectID,TeamID,WorkflowID,CurrentStepID,ParentTaskID,Title,Description,Priority,Status,State,NeedsApproval,IsApproved,ApprovedBy,AssigneeID,CreatedBy,StartDate,DueDate,FinishedAt,CreatedAt,UpdatedAt,ProgressPercent from public.Task where ID=?
20260425 19490460 E EXC ESqlDBPostgres {Message:"TSqlDBPostgresLib Exec failed: [message contents do not agree with length in message type \"T\"\nserver sent data (\"D\" message) without prior row description (\"T\" message)\n]",Statement:null} [conn-5] at 7ff625c7f4c5 {4 3.00 65533.29 13 11GB/15.6GB 24.2GB/30.6GB 23f00f01}Both threads were handling the same two service methods (ViTaskService.ViewTask and ViTaskService.GetDetail) concurrently, using sicPerThread instance mode.
The Statement field in the exception object is null, suggesting the statement reference was lost or corrupted at the time of the error.
Environment:
mORMot version: 2.4.14728
PostgreSQL: 127.0.0.1:5432, libpq v170006
OS: Windows 10 x64
App: x64
Service instance mode: sicPerThread
Thread pool size: 32
Last edited by Kabiri (Yesterday 20:17:03)
Offline
Use the async HTTP server to have a stable pool of threads.
OK, I’ll do it.
Offline