Skip to content

[CDC] pg_logical_emit_message with transactional := true crashes the backend and restarts the postmaster #33188

Description

@yugabyte-ci

Jira Link: DB-22894

Description

SELECT pg_logical_emit_message(true, 'prefix', 'payload') crashes the YSQL backend
with an assertion failure, and the postmaster then hits a second assertion while
reaping the dead backend, so the whole PostgreSQL instance restarts rather than
just the one connection. The non-transactional form (transactional := false)
is unaffected.

Steps to reproduce

Start a cluster (debug build) and run, in ysqlsh:

SELECT pg_logical_emit_message(true, 'pgoutput', 'a transactional message');

The connection drops with server closed the connection unexpectedly, and the
postmaster restarts with database system was not properly shut down; automatic recovery in progress.

This is also reachable through the upstream logical replication test suite:
src/test/subscription/t/020_messages.pl fails at line 50 against a YugabyteDB
publisher for exactly this reason.

Backend assertion

TRAP: FailedAssertion("!TransactionIdIsValid(proc->xid)",
      File: "src/postgres/src/backend/storage/ipc/procarray.c", Line: 728)

  ExceptionalCondition
  ProcArrayEndTransaction        procarray.c:728
  CommitTransaction              xact.c:2555
  CommitTransactionCommand       xact.c:3489
  finish_xact_command            postgres.c:3266
  exec_simple_query              postgres.c:1626
  yb_exec_simple_query_impl      postgres.c:6237
  ...
STATEMENT:  SELECT pg_logical_emit_message(true, 'pgoutput', 'a transactional message')

Followed, in the postmaster, by:

TRAP: FailedAssertion("!TransactionIdIsValid(ProcGlobal->xids[myoff])",
      File: "src/postgres/src/backend/storage/ipc/procarray.c", Line: 629)

  ExceptionalCondition
  ProcArrayRemove
  ...
  PostmasterMain

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions