Skip to content

Npgsql.NpgsqlException (0x80004005): Received backend message RowDescription while expecting ParseCompleteMessage. Please file a bug. #2201

Closed

Description

@maikebing

Exception message:

Oct 23 00:02:41 kpwkafka iothub[52602]: Npgsql.NpgsqlException (0x80004005): Received backend message RowDescription while expecting ParseCompleteMessage. Please file a bug.
Oct 23 00:02:41 kpwkafka iothub[52602]: at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming)
Oct 23 00:02:41 kpwkafka iothub[52602]: at Npgsql.NpgsqlDataReader.NextResult()
Oct 23 00:02:41 kpwkafka iothub[52602]: at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
Oct 23 00:02:41 kpwkafka iothub[52602]: at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
Oct 23 00:02:41 kpwkafka iothub[52602]: at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)
Oct 23 00:02:41 kpwkafka iothub[52602]: at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
Oct 23 00:02:41 kpwkafka iothub[52602]: at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
Oct 23 00:02:41 kpwkafka iothub[52602]: at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
Oct 23 00:02:41 kpwkafka iothub[52602]: at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()
Oct 23 00:02:41 kpwkafka iothub[52602]: at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider._TrackEntities[TOut,TIn](IEnumerable`1 results, QueryContext queryContext, IList`1 entityTrackingInfos, IList`1 entityAccessors)+MoveNext()
Oct 23 00:02:41 kpwkafka iothub[52602]: at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
Oct 23 00:02:41 kpwkafka iothub[52602]: at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
Oct 23 00:02:41 kpwkafka iothub[52602]: at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

Further technical details

Npgsql version:2.1.2
PostgreSQL version: PostgreSQL 10.1
Operating system: (Red Hat 4.4.7-16), 64-bit

Activity

  1. maikebing commented on Oct 23, 2018

    @maikebing
    Author

    It seems that the new version of PG will not have this problem, perhaps the version difference?

  2. roji commented on Nov 19, 2018

    @roji
    Member

    Sorry for taking so long with this. Does this bug happen in a regular way, or randomly? I'm very interested in working on it, but I'll need some sort of code sample that reproduces it. Is it possible to put together a small console app for this?

  3. maikebing commented on Nov 19, 2018

    @maikebing
    Author

    Appears to be caused by multithreaded execution of SQL statements with the same connection. That seems to be the case.

  4. maikebing commented on Nov 19, 2018

    @maikebing
    Author

    It's been a long time, and I don't remember it very well.

  5. roji commented on Nov 19, 2018

    @roji
    Member

    OK, thanks for getting back to me - multithreaded execution on the same connection would definitely produce this kind of error.

    I'll close this for now, but if this happens again post back and we'll revisit.

  6. worldleaderpretend commented on Jun 25, 2019

    @worldleaderpretend

    Hello, I also ran into this a few times while using a listener. I finally traced it back to a race condition with the cancellation token. Seems if a cancelled token gets sent to WaitAsync(), then the next command fails with this error. Here's some sample code (TableA is a non-existent). I tested with 4.0.7:

    using (NpgsqlConnection connection = new NpgsqlConnection(connectionString))
    {
        connection.Open();
    
        using (NpgsqlCommand command = new NpgsqlCommand("LISTEN TableA", connection))
        {
            command.ExecuteNonQuery();
        }
    
        using (CancellationTokenSource tokenSource = new CancellationTokenSource())
        {
            try
            {
                tokenSource.Cancel();
    
                connection.WaitAsync(tokenSource.Token).Wait();
            }
            catch (AggregateException ex) when (ex.InnerExceptions.Any(x => (x is TaskCanceledException)))
            {
            }
        }
    
        using (NpgsqlCommand command = new NpgsqlCommand("SELECT NULL", connection))
        {
            command.ExecuteNonQuery();
        }
    }
    
    
  7. worldleaderpretend commented on Jun 26, 2019

    @worldleaderpretend

    Opened a new issue: #2506

  8. n-ae commented on Jun 16, 2021

    @n-ae

    This happened to me when I put a breakpoint between two new async connections a select, second an insert. It's only thrown when the to-be-inserted List was empty, and that the breakpoint is after the first connection and before the second. Tested with 5.0.7.

  9. roji commented on Jun 16, 2021

    @roji
    Member

    @bali-ibrahim please open a new issue with a runnable code sample, so that we can investigate.

  10. n-ae commented on Jun 20, 2021

    @n-ae

    @roji I am sorry to have misinformed you, I couldn't reproduce it for 5.0.7 however, I could for 5.0.5 with the abovementioned scenario.

    I can try to come up with a minimal reproducible example if it would still be helpful.

  11. roji commented on Jun 20, 2021

    @roji
    Member

    @bali-ibrahim if you can reproduce the bug for 5.0.5 and not for 5.0.7, then we've probably fixed it - it's recommended to always run on the latest patch level of Npgsql. If you can reproduce a bug with the latest patch level, a new issue with a minimal example would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions