Skip to content

TimelineHistory throws InvalidCastException on PostgreSQL 14+, Show("all") breaks the connection, ReplicationConnection.CommandTimeout is ignored #6695

Closed

Description

@Brar
  • TimelineHistory throws InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Byte[]' on PostgreSQL 14 and later. Since postgres 66a8f090485 (14.0) the server declares the content column as text instead of bytea, so the command helper returns a string, which TimelineHistory casts to byte[] (ReplicationConnection.cs:340-341, 786-788). Every release tested fails this way on 14.24 and 18.6: 5.0.0, 5.0.18, 6.0.13, 7.0.10, 8.0.9, 9.0.5 and 10.0.3, except that 5.0.0 already fails at IDENTIFY_SYSTEM on 18.6. 10.0.3 also fails on 15.19, 16.15 and 17.11. Each run used a cluster promoted onto timeline 2. CI has no test that reads it, since CommonReplicationTests.TimelineHistory is [Explicit] (CommonReplicationTests.cs:143-145).
  • Show("all") returns many rows, but the command helper reads one DataRow and then expects CommandComplete, so the second row breaks the connection: "Received backend message DataRow while expecting CommandCompleteMessage. Please file a bug." (ReplicationConnection.cs:771, 834, Statics.cs:56-59).
  • ReplicationConnection.CommandTimeout has no effect on replication commands: every command starts a user action, which resets the timeouts to the connection string's Command Timeout (NpgsqlConnector.cs:2713-2717). Setting the property before Open() throws InvalidOperationException (ReplicationConnection.cs:179-181, 199).
  • PhysicalReplicationConnection.StartReplication(null, cancellationToken) throws NullReferenceException instead of ArgumentNullException (PhysicalReplicationConnection.cs:181).

The same code is on the 8.0, 9.0 and 10.0 hotfix branches.

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
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

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions