Skip to content

Replication: MoveNextAsync throws NullReferenceException after the connection broke while a message was held #6700

Description

@Brar

If the connection breaks while the consumer is processing a message, e.g. because the feedback timer's status update failed on a dropped network, the timer only logs the failure (ReplicationConnection.cs:654-657), and breaking the connector disposes and clears its buffers (NpgsqlConnector.cs:2448-2453). The consumer's next MoveNextAsync then throws NullReferenceException, e.g. in NpgsqlConnector.ReadMessage, instead of an exception that says why the connection broke. A failed SendStatusUpdate has the same effect. On main with PostgreSQL 18.6, both a timer status update that failed after pg_terminate_backend and a failed SendStatusUpdate made the next MoveNextAsync throw that NullReferenceException in NpgsqlConnector.ReadMessage. A failed SendStatusUpdate did the same with 14.24, and in some runs gave an NpgsqlException over ObjectDisposedException instead. #6630 doesn't change this; it fixed the exceptions that SendStatusUpdate itself threw while the stream was being torn down.

The 8.0, 9.0 and 10.0 hotfix branches have the same code on this path, so they fail the same way (inferred).

Activity

  1. added this to the 11.0.0 milestone on Oct 25, 2026
  2. self-assigned this
    on Oct 25, 2026
  3. added theissue type on Oct 25, 2026
  4. modified the milestones: 11.0.0, 12.0.0 on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions