New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.NullReferenceException at Npgsql.NpgsqlConnector.Cleanup() #1667
Comments
Can you reproduce this exception in a reliable way, and submit a code sample which reproduces it? If not, I've seen this before when the same connection is used concurrently from multiple threads, which isn't allowed. Can you please confirm that this isn't the case here? |
Found same problem on 3.2.5:
|
This call stack was taken from a single session IIS application. It has a connection pool shared by all sessions with a maximum size of 1:
It occurs with milliseconds after logging on, when requesting the views. So it is multi-thread application with at most one SQL statement active and/or open. |
Occurs consistently 50 times per day out of approximately 250 tries. Postgresql 9.6. |
@monty241, any chance you're trying to close a connection that's currently executing a command, due to a race condition? If so, this is a known issue and not currently supported. |
Hi @roji , thanks for fast addition. No, during initialization of the connection we do the following steps:
The first steps are executed sequentially and protected by a lock. It nonetheless tries to close a previous connection to PostgreSQL through NPGSQL 25 ms earlier, but that call succeeds. Just to be sure: what is issue# of that issue? Maybe I can analyze the code to completely rule that possible cause out. |
Added some measurements in code to be able to better analyze cause and will plugin npgsql logger in our logging framework. Might it be that with CurrentReader.Command.State the CurrentReader.Command == null ? |
@monty241 from your stack trace it seems that the error occurs while attempting to "break" a connection - this happens when an unrecoverable error occurs (e.g. broken network connection). I can try to look, but the best way forward is if you can produce a code sample which reproduces this? I don't need a 100% repro, but something which runs in a loop and does 50% would be more than enough. However, please try to avoid IIS/ASP.NET/other heavy APIs or libraries. |
After adding npgsql logging problem and upgrading infrastructuer problem not yet seen. |
Closing for age, since no repro has been submitted and in any case the issue may be gone. |
Correct, problem never seen again after adding npgsql logging. Apologies for not updating this issue. |
Npgsql 3.2.5.
The text was updated successfully, but these errors were encountered: