#1 Yesterday 17:36:26

Kabiri
Member
Registered: 2024-06-22
Posts: 60

mORMot + PostgreSQL: "lost synchronization with server" when switching

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 "..."]

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.

Offline

#2 Yesterday 22:27:12

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

Re: mORMot + PostgreSQL: "lost synchronization with server" when switching

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

Board footer

Powered by FluxBB