github vibhorkum/pg_background v1.9.2
pg_background v1.9.2 - Assert-Enabled Build Fix

5 hours ago

Bug Fix

This patch release fixes an assertion failure that occurred on assert-enabled PostgreSQL builds (such as Debian's apt.postgresql.org unstable packages).

CopyErrorData Memory Context Assertion (PR #102)

Before: Workers encountering SQL errors (e.g., SELECT 1/0) would crash on assert-enabled builds with:

TRAP: FailedAssertion("CurrentMemoryContext != ErrorContext", File: "elog.c", Line: 1575)
LOG:  background worker "pg_background" was terminated by signal 6: Aborted

Root cause: The v1.9 structured error capture code called CopyErrorData() inside PG_CATCH() without first switching out of ErrorContext. PostgreSQL asserts this to prevent use-after-free bugs.

Fix: Add MemoryContextSwitchTo(TopMemoryContext) before CopyErrorData(), following standard PostgreSQL error handling patterns.

CI Improvements

  • Added test-assert.sh for testing with --enable-cassert PostgreSQL builds
  • CI now runs assert-enabled tests on PostgreSQL 14 and 17 to catch memory context bugs early

Who Should Upgrade

  • Users running on Debian/Ubuntu with apt.postgresql.org unstable packages
  • Users building PostgreSQL from source with --enable-cassert
  • All users are recommended to upgrade for improved stability

Note: The PostgreSQL extension version remains 1.9 (no SQL changes). This is a C-only patch release.

Installation

-- If upgrading from v1.9 or v1.9.1, just reinstall the shared library
DROP EXTENSION pg_background;
CREATE EXTENSION pg_background;

Full Changelog

  • fix: switch memory context before CopyErrorData in worker error handler (#102)
  • ci: add assert-enabled PostgreSQL tests

Don't miss a new pg_background release

NewReleases is sending notifications on new releases.