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