postgresql-interfaces/psqlodbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feed[postgresql-interfaces/psqlodbc] issue #90: Unhandled exception on next query after network connection is disconnected then re-connected.
4+ messages / 2 participants
[nested] [flat]
* [postgresql-interfaces/psqlodbc] issue #90: Unhandled exception on next query after network connection is disconnected then re-connected.
@ 2025-02-14 13:58 "tazervas (@tazervas)" <[email protected]>
0 siblings, 0 replies; 4+ messages in thread
From: tazervas (@tazervas) @ 2025-02-14 13:58 UTC (permalink / raw)
To: postgresql-interfaces/psqlodbc <[email protected]>
If the network connection is lost and then re-connected during an ODBC session using version 17.00.0004 the next query will throw an "Attempted to read or write protected memory" exception which cannot be caught. Version 16.00.00 throws exception "The connection has been disabled (or lost). ERROR [08S01] server closed the connection unexpectedly" which can be caught and acted upon which is the desired behavior.
Example Visual Studio 2022 .NET 8 Windows Forms Visual Basic code which demonstrates this issue:
Try
Dim cs As New Odbc.OdbcConnectionStringBuilder
cs.Clear()
cs.Driver = "PostgreSQL Unicode(x64)"
cs.Add("Database", "database")
cs.Add("Servername", "host")
cs.Add("UID", "user")
cs.Add("PWD", "password")
Dim c As Odbc.OdbcConnection = New Odbc.OdbcConnection With {.ConnectionString = cs.ConnectionString}
c.Open()
Dim sql As Odbc.OdbcCommand = c.CreateCommand
sql.CommandType = CommandType.Text
sql.CommandText = "SELECT count(*) FROM anytable"
sql.ExecuteScalar()
MsgBox("psqlODBC exception test: disconnect then re-connect network")
sql.ExecuteScalar() ' unhandled exception here
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Exception text:
System.AccessViolationException
HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
[Managed to Native Transition]
System.Data.Odbc.dll!System.Data.Odbc.OdbcConnectionHandle.ReleaseHandle() Unknown
System.Private.CoreLib.dll!System.Runtime.InteropServices.SafeHandle.InternalRelease(bool disposeOrFinalizeOperation) Unknown
System.Private.CoreLib.dll!System.Runtime.InteropServices.SafeHandle.Dispose() Unknown
System.Data.Odbc.dll!System.Data.Odbc.OdbcConnection.Close() Unknown
System.Data.Odbc.dll!System.Data.Odbc.OdbcConnection.ConnectionIsAlive(System.Exception innerException) Unknown
System.Data.Odbc.dll!System.Data.Odbc.OdbcConnection.HandleErrorNoThrow(System.Data.Odbc.OdbcHandle hrHandle, System.Data.Odbc.ODBC32.SQLRETURN retcode) Unknown
System.Data.Odbc.dll!System.Data.Odbc.OdbcConnection.HandleError(System.Data.Odbc.OdbcHandle hrHandle, System.Data.Odbc.ODBC32.SQLRETURN retcode) Unknown
System.Data.Odbc.dll!System.Data.Odbc.OdbcCommand.ExecuteReaderObject(System.Data.CommandBehavior behavior, string method, bool needReader, object[] methodArguments, System.Data.Odbc.ODBC32.SQL_API odbcApiMethod) Unknown
System.Data.Odbc.dll!System.Data.Odbc.OdbcCommand.ExecuteReaderObject(System.Data.CommandBehavior behavior, string method, bool needReader) Unknown
System.Data.Odbc.dll!System.Data.Odbc.OdbcCommand.ExecuteScalar() Unknown
> psqlodbc_17_0004_exception.dll!psqlodbc_17_0004_exception.Form1.Form1_Load(Object sender, System.EventArgs e) Line 43 Basic
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #90: Unhandled exception on next query after network connection is disconnected then re-connected.
@ 2025-02-28 19:51 "tazervas (@tazervas)" <[email protected]>
2 siblings, 0 replies; 4+ messages in thread
From: tazervas (@tazervas) @ 2025-02-28 19:51 UTC (permalink / raw)
To: postgresql-interfaces/psqlodbc <[email protected]>
Verified that 16.00.0006 also fails with same AccessViolationException. Verified that 16.00.0005 does NOT fail with AccessViolationException instead throws "The connection has been disabled (or lost). ERROR [08S01] server closed the connection unexpectedly" as expected and desired. Suspect that one of the changes within .0006 is involved however in reviewing them I did not see anything that was obviously wrong.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #90: Unhandled exception on next query after network connection is disconnected then re-connected.
@ 2025-04-24 05:02 "harukat (@harukat)" <[email protected]>
2 siblings, 0 replies; 4+ messages in thread
From: harukat (@harukat) @ 2025-04-24 05:02 UTC (permalink / raw)
To: postgresql-interfaces/psqlodbc <[email protected]>
If you had connection pooling enabled by the driver manager when this occurred, it may be the same phenomenon I encountered.
I am proposing the following modifications to it.
https://github.com/postgresql-interfaces/psqlodbc/pull/113
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #90: Unhandled exception on next query after network connection is disconnected then re-connected.
@ 2025-04-28 18:59 "tazervas (@tazervas)" <[email protected]>
2 siblings, 0 replies; 4+ messages in thread
From: tazervas (@tazervas) @ 2025-04-28 18:59 UTC (permalink / raw)
To: postgresql-interfaces/psqlodbc <[email protected]>
> If you had connection pooling enabled by the driver manager when this occurred, it may be the same phenomenon I encountered. I am proposing the following modifications to it.
>
> [#113](https://github.com/postgresql-interfaces/psqlodbc/pull/113)
Confirmed. I had connection pooling enabled.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2025-04-28 18:59 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-02-14 13:58 [postgresql-interfaces/psqlodbc] issue #90: Unhandled exception on next query after network connection is disconnected then re-connected. "tazervas (@tazervas)" <[email protected]>
2025-02-28 19:51 ` "tazervas (@tazervas)" <[email protected]>
2025-04-24 05:02 ` "harukat (@harukat)" <[email protected]>
2025-04-28 18:59 ` "tazervas (@tazervas)" <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox