From: sergey-krasnogorov (@sergey-krasnogorov) <noreply+sergey-krasnogorov@github.com>
To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com>
Subject: [postgresql-interfaces/psqlodbc] issue #224: psqlODBC driver or MS System.Data.Odbc do not report connection lost
Date: Mon, 26 Oct 2026 07:06:13 +0000
Message-ID: <gh-postgresql-interfaces-psqlodbc-224@github.com> (raw)
Dear psqlODBC maintainers,
I would like to ask a couple of questions about MS ODBC API / psqlodbc driver interaction and whether it is expected behavior.
Summary
We are observing intermittent lost connection issues in a .NET application using:
PostgreSQL: 18.6 running as Windows Service
psqlODBC: 18.00.0005
Windows: x64
Driver: PostgreSQL Unicode (x64)
The failure occurs after replacing entire database cluster directory on filesystem with another one (created earlier, same database, same settings, kind of “restoring database to the previously saved state”).
Scenario #1:
1. Stop database service
2. Replace database cluster directory with another one
3. Start database service
4. Immediately open OdbcConnection
5. OdbcConnection.State is Open
6. Immediately execute System.Data.Odbc.OdbcCommand
7. Exception: The connection has been disabled.
8. OdbcConnection.State is Closed
That is somehow Ok, connection state is determined, reconnecting helped.
Scenario #2:
1. Stop database service
2. Replace database cluster directory with another one
3. Start database service
4. Immediately open OdbcConnection
5. OdbcConnection.State is Open
6. Immediately execute System.Data.Odbc.OdbcCommand
7a. Exception: ERROR [08S01] The connection is down
7b. Exception: ERROR [08S01] SQLExecDirectW unable due to the connection lost
9. OdbcConnection.State is Open
Reported connection state is wrong, no reconnecting performed, all subsequent queries result in “ERROR [08S01] SQLExecDirectW unable due to the connection lost”.
Questions:
1. Might it be some timing issue after replacing database cluster?
E.g. if we delay connection/query for some measurable time (2-10 sec) we never observed such type of unexpected disconnecting.
2. Why OdbcConnection.State remains Open after numerous query failures?
Shouldn’t the driver detect it after the first unsuccessful query due to connection lost?
Thank you for your time and for maintaining psqlODBC.
Best regards,
Sergey Krasnogorov