npgsql: Received unexpected backend message DataRow on INSERT
The issue
We have had two instances of the following error being thrown from NpgsqlDataReader.NextResult:
Exception message: "Received unexpected backend message DataRow. Please file a bug."
Stack trace:
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming)
at Npgsql.NpgsqlDataReader.NextResult()
at Npgsql.NpgsqlCommand.ExecuteDbDataReader(...)
at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
The error has always happened with an INSERT that also has a SELECT inside it, something like:
INSERT INTO table (column1, column2, column3) VALUES (1, 'a', (SELECT COALESCE(MAX(column3), -1) FROM table WHERE column1 = @someId)+1)
That may be pure coincidence but I wanted to mention it.
Further technical details
Npgsql version: 4.0.0-rc1 PostgreSQL version: 9.6 Operating system: Windows Server 2012 R2
Other details about my project setup: We saw this error happen as we started out a rollout of a new version of our software. We have just upgraded to Npgsql 4.0.1 so we will see if we still get this error after that. I couldn’t find any spicific issue between 4.0.0-rc1 and 4.0.1 that would have fixed this (though there were a lot of changes) so I wanted to just open this to be safe and give you a heads up.
If you need any more details or anything please let me know.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (7 by maintainers)
@roji I will try to reproduce it with a simple program. I have never seen these exception in our testing environment but maybe thats because there is way less load on the system.
Meanwhile here is my connection string:
Server=xxx;Port=5432;Database=xxx;User Id=xxx;Password=xxx;Keepalive=30;CommandTimeout=1800;Timeout=30;We are using dapper and also polly for the retry logic. Here is a full stacktrace: