void-packages icon indicating copy to clipboard operation
void-packages copied to clipboard

PostgreSQL 16 initdb fails with dict_snowball.so: undefined symbol: CurrentMemoryContext

Open Xiong-Tian opened this issue 1 year ago • 4 comments

Is this a new report?

Yes

System Info

Void 5.10.160 aarch64 Unknown uptodate rrnFFFF

Package(s) Affected

postgresql16-16.2_1

Does a report exist for this bug with the project's home (upstream) and/or another distro?

https://lore.kernel.org/buildroot/[email protected]/

Expected behaviour

PostgreSQL 16 initdb succeeds

Actual behaviour

When the postgresql16 service is started without existing data, initdb is run and yields: FATAL: could not load library "/usr/lib/psql16/lib/postgresql/dict_snowball.so": /usr/lib/psql16/lib/postgresql/dict_snowball.so: undefined symbol: CurrentMemoryContext It then remains stuck in a loop trying to run initdb and failing. This appears to affect aarch64 but not x86_64.

Steps to reproduce

Install fresh copy of PostgreSQL 16 (on aarch64) Start the postgresql16 service or run initdb manually

Xiong-Tian avatar May 27 '24 00:05 Xiong-Tian

Getting the same issue on Void Linux 6.6.42_1 aarch64 (4KiB page kernel for the Raspberry Pi/kernel8).

Oct 20 03:32:15 [postgresql16] creating configuration files ... ok
Oct 20 03:32:15 [postgresql16] running bootstrap script ... ok
Oct 20 03:32:15 [postgresql16] performing post-bootstrap initialization ... 2024-10-20 03:32:15.650 IST [14834] FATAL:  could not load library "/usr/lib/psql16/lib/postgresql/dict_snowball.so": /usr/lib/psql16/lib/postgresql/dict_snowball.so: undefined symbol: CurrentMemoryContext
Oct 20 03:32:15 [postgresql16] 2024-10-20 03:32:15.650 IST [14834] STATEMENT:  CREATE FUNCTION dsnowball_init(INTERNAL)
Oct 20 03:32:15 [postgresql16] _    RETURNS INTERNAL AS '$libdir/dict_snowball', 'dsnowball_init'
Oct 20 03:32:15 [postgresql16] _LANGUAGE C STRICT;
Oct 20 03:32:15 [postgresql16] _
Oct 20 03:32:15 [postgresql16] child process exited with exit code 1
Oct 20 03:32:15 [postgresql16] initdb: removing contents of data directory "/var/lib/postgresql16/data"

Could be related to cross-compiling and the potential fix has already been mentioned by OP.

Skaytacium avatar Oct 19 '24 22:10 Skaytacium

Any updates? The same problem on postgresql17.

foresle avatar Sep 16 '25 18:09 foresle

The fix works, applied as a patch and cross-recompiling the package:.

  1. Create a patch, put it in void-packages/srcpkgs/postgresql17/patches/cross-compiling.patch
--- a/configure 2025-11-06 14:59:27.408860429 +0100
+++ b/configure 2025-11-06 14:59:38.269624917 +0100
@@ -19224,7 +19224,7 @@
   pgac_save_LDFLAGS=$LDFLAGS
 LDFLAGS="$pgac_save_LDFLAGS -Wl,--export-dynamic"
 if test "$cross_compiling" = yes; then :
-  pgac_cv_prog_cc_LDFLAGS_EX_BE__Wl___export_dynamic="assuming no"
+  pgac_cv_prog_cc_LDFLAGS_EX_BE__Wl___export_dynamic=yes
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
  1. Restart cross-compilation
./xbps-src -a aarch64 pkg postgresql17
  1. Copy postgresql17* and new index to the target machine (adapt accordingly):
rsync hostdir/binpkgs/aarch64-repodata user@target:/path/to/local-packages/
rsync hostdir/binpkgs/postgresql* user@target:/path/to/local-packages/
  1. Install the newly created package (on the target)
sudo xbps-install postgresql postgresql17
  1. Restart the initdb procedure:
sudo chpst -u postgres initdb --locale=C.UTF-8 --encoding=UTF8 -D /var/lib/postgresql/data --data-checksums

[...]
Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

Hope this helps!

dvergeylen avatar Nov 06 '25 14:11 dvergeylen