SCM

[#1010321] Socket errors in BeginTransaction not properly handled

View Trackers | Bugs | Download .csv | Monitor

Date:
2008-03-19 20:58
Priority:
3
State:
Open
Submitted by:
Matthew Gabeler-Lee (cheetah)
Assigned to:
Nobody (None)
Npgsql Version:
2.0
Category:
Group:
Resolution:
None
Summary:
Socket errors in BeginTransaction not properly handled

Detailed description
Scenario: Attempting to begin a transaction on a connection retreived from the pool whose socket connection to the server has been killed (network problems, etc.)

What Happens:

BeginTransaction tries to send the BEGIN and isolation level commands to the server. NpgsqlCommand.ExecuteCommand gets and catches an IOException. It calls ClearPoolAndThrowException. ClearPoolAndThrowException tries to call Connection.ClearPool, and that throws a NullReferenceException.

The NpgsqlCommand created in this way does not have a Connection object assigned to it at this point (that may be the problem right there), and so Connection is null and it can't call the ClearPool method. Looking at the source and analyzing things with Reflector, it looks like the only way connection gets assigned is through the constructor that takes one, and BeginTransaction uses a different constructor.

The excellent (read: horrible) side effect of this failure is the dead connection stays in the pool at the top of the queue and so it gets used preferentially, effectively killing the app :(

Followup

No Followups Have Been Posted

Attached Files:

Changes:

No Changes Have Been Made to This Item

Powered By FusionForge