Databases

PostgreSQL plperl functions crash server backend with SIGSEGV after system Perl upgrade

Environment

Environment

PostgreSQL 13.8 on CentOS 7 hosts, plperl installed and used for several stored procedures. System Perl recently upgraded from 5.16 to 5.30 via vendor-supplied package; perl-modules and shared libraries updated. PostgreSQL installed from RPMs and plperl linked against system Perl.

Symptoms

Symptoms

Invoking plperl function causes backend to crash (segfault). PostgreSQL logs show 'server process (PID) exited with exit code 1' and core dump generated. After crash, clients attempting to call plperl get 'could not connect to server: Connection refused' until postmaster restarts. Non-plperl functions continue to work.

Observations

Observations

gdb backtrace from core shows crash inside XS call into Perl interpreter (e.g., sv_magicext, perl_alloc). reinstalling PostgreSQL server package without changing Perl does not help. Running perl -v shows new version 5.30. plpython and other procedural languages unaffected. ldconfig shows multiple libperl.so.* versions in /usr/lib64.

Already attempted

Already attempted

Rebuilt plperl from source against current Perl headers (attempt in staging) which prevented crash in that build, indicating ABI mismatch. On production, attempted to yum downgrade Perl packages but package manager held other dependent packages. Did not alter database binaries in production environment; created new test database on staging to confirm rebuild resolves segfault.

Question

Question

What reversible steps can I take on production to restore plperl stability without risking data, and how should I decide between rebuilding plperl, downgrading system Perl, or isolating plperl use?

COMMUNITY RESPONSES

Verified community troubleshooting

0 replies

No answers yet..

Showing 0 of 0 community responses
AI DIAGNOSTICS

Incident analysis

Updated 2d ago• Trouble ID

Most likely causes

ABI incompatibility between plperl shared object and upgraded system Perl (symbol/struct layout changed). 95%
Packaged PostgreSQL plperl built against older Perl and not compatible with the vendor Perl update. 90%
Multiple libperl versions present and runtime linking resolving to wrong SONAME due to LD_LIBRARY_PATH or rpath differences. 40%

Summary

plperl embeds the system Perl interpreter; a Perl ABI change (major version jump) causes plperl's compiled shared object to call into incompatible symbols, producing SIGSEGV. The staging rebuild fixing the issue points to ABI mismatch between plperl and system Perl. Safe remediation paths: rebuild plperl against the current Perl (preferred), use a database package built for the current distro Perl, or avoid plperl by refactoring functions into PL/pgSQL or external services. Downgrading system Perl can break other packages and is high risk.

Suggested Fixes

Diagnostic step 1
Do not edit or delete database files. Collect evidence: copy core file and run gdb on a staging replica to produce a backtrace; capture 'ldd $(pg_config --pkglibdir)/plperl.so' to see linked libperl path.
Diagnostic step 2
Build and test a plperl.so on an isolated staging node against the current system Perl and run the failing functions there. If successful, plan a production rebuild and package the module as an RPM for consistent rollout.
Diagnostic step 3
If rebuilding in-place is not possible immediately, create safe bypass by migrating critical plperl procedures to SQL/PLpgSQL or an external microservice to reduce immediate crash surface.

Continue troubleshooting

Matched from the title, description and tags