FULL AI ANALYSIS

Autovacuum worker SIGSEGV after PostgreSQL 13→14 upgrade when extension is loaded via shared_preload_libraries

Generated Oct 13, 2026, 9:45:52 AM

Analysis summary

Behavior indicates the extension is either not safe to be loaded into background worker contexts or compiled against an incompatible server ABI. shared_preload_libraries causes the extension's init code to run in all server processes (including autovacuum background workers). If the extension registers hooks, uses non-backend-safe APIs, assumes a backend-only environment, or relies on global state initialized differently per process, it can corrupt memory or dereference invalid pointers in autovacuum workers. The fact that manual use of the extension in a normal backend is safe suggests the fault is in code paths executed only when loaded at process start (initialization hooks, background-worker registration, or global constructors). A mismatch between extension binary and PostgreSQL server ABI (recompilation required) is also a common root cause after an upgrade.

Possible causes

Extension uses global/static state not initialized safely across forked background processes, causing memory corruption.

90%

Extension init/register hooks call non-SPI-safe functions or allocate shared memory incorrectly when invoked in autovacuum process context.

70%

Extension interacts with system libraries that changed behavior across OS or compiler versions (allocator or thread-safety differences).

25%

Extension binary built against PostgreSQL 13 ABI; incompatible with PostgreSQL 14 internal structures used during background worker init.

20%

Suggested fixes

1

Diagnostic step 1

Remove the extension from shared_preload_libraries (already tested) to stop crashes — reversible and minimal disruption.

2

Diagnostic step 2

Rebuild the extension from source against the exact PostgreSQL 14 server headers and link flags used by the running server; test on a staging instance with autovacuum under realistic load before deploying to production.

3

Diagnostic step 3

If the extension must be preloaded, audit its code (or request vendor audit) for background-worker safe patterns: avoid non-reentrant globals, guard initialization with ProcessIsBackgroundWorker checks, use appropriate memory contexts, and avoid calling backend-only APIs during early init. Run with AddressSanitizer or valgrind in staging to detect memory issues.

4

Diagnostic step 4

If rebuilding or fixing the extension is not possible, consider loading the extension on-demand per-database (CREATE EXTENSION) rather than preloading, or schedule manual vacuums as a temporary maintenance workaround while you remediate.

5

Diagnostic step 5

Collect core dumps, server build ids, extension binary build metadata, and reproduce steps and file a bug with the extension author or vendor. Escalate to the extension maintainer if the extension is closed-source or if you suspect an ABI change caused the crash.