Skip to content

Deadlock/hung at NpgsqlDataReader.Cleanup  #4465

@ghost

Description

The issue

We encountered what appears to be a deadlock on a production system.
We took a memory dump of the process and analyzed it - where we appear to be deadlocked is in NpgsqlDataReader.Cleanup at _sendTask.GetAwaiter().GetResult():

Npgsql.dll!Npgsql.NpgsqlDataReader.Cleanup
[External Code]
[Waiting on Async Operation, double-click or press enter to view Async Call Stacks]
Npgsql.dll!Npgsql.NpgsqlDataReader.Cleanup(bool async, bool connectionClosing, bool isDisposing) Line 1017
Npgsql.dll!Npgsql.NpgsqlDataReader.Close(bool connectionClosing, bool async, bool isDisposing) Line 998
Npgsql.dll!Npgsql.NpgsqlDataReader.Dispose(bool disposing) Line 890
Dapper.dll!Dapper.SqlMapper.QueryImpl<int>(System.Data.IDbConnection cnn, Dapper.CommandDefinition command, System.Type effectiveType) Line 1120
[External Code]
Dapper.dll!Dapper.SqlMapper.Query<int>(System.Data.IDbConnection cnn, string sql, object param, System.Data.IDbTransaction transaction, bool buffered, int? commandTimeout, System.Data.CommandType? commandType) Line 734

We have been running v6.0.3 for several weeks and this is the first time this happened and unfortunately have not been able to reproduce this scenario in our development environment.

For our end, all we're doing is using a dedicated thread that pulls messages out of a queue and inserts them (mapped via dapper):

using (var cnn = CreateConnection())
{
	obj.Id = cnn.Query<int>("my insert statement", obj).First();
}

Further technical details

Npgsql version: 6.0.3
PostgreSQL version: 10.4
Operating system: Windows Server 2019

Other details about my project setup:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions