feat: require shared_preload_libraries for pg_textsearch#235
Merged
Conversation
d852e41 to
e4b88d1
Compare
Without shared_preload_libraries, each backend loads the .so independently via dlopen. If the .so file is replaced on disk (e.g., during a deployment) without restarting Postgres, different backends get different code, causing a fatal ShmemIndex entry size mismatch. Requiring shared_preload_libraries ensures all backends use the same .so inherited from the postmaster via fork, eliminating this class of bugs. Changes: - Add check in _PG_init() that errors if not loaded during shared_preload_libraries processing - Remove lazy init fallbacks in registry.c (tp_registry_get_dsa and tp_registry_is_registered) - Update all test infrastructure: Makefile test-local, shell scripts (concurrency.sh, recovery.sh, segment.sh, cic.sh), and all CI workflows (ci, coverage, sanitizer, nightly-stress, benchmark, upgrade-tests) - Update CLAUDE.md to document the requirement
e4b88d1 to
9bc6483
Compare
The revert of versioned shared library filenames (#238) removed the PG_TEXTSEARCH_LIB_NAME macro, breaking the shared_preload_libraries check added in the previous commit.
Add the shared_preload_libraries configuration step to the README Getting Started section. Update CLAUDE.md to remove stale reference to versioned library name and note that a server restart is needed after updating the binary during development.
After the revert of versioned shared library filenames (#238), the library is just pg_textsearch.so. Update all CI workflows and shell test scripts that were still constructing the versioned name.
v0.1.0 extension SQL references functions (e.g., bm25_get_current_score) that no longer exist in the current binary. This test was previously passing on main only because the versioned shared_preload_libraries name failed silently, allowing the old SQL to load without the C library. With shared_preload_libraries now enforced, this path is no longer viable. Upgrades from v0.2.0+ continue to be tested in test-upgrades.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
shared_preload_librariesto prevent fatalShmemIndex entry size is wrongerrors when the .so is replaced during deployment without a server restartshared_preload_librarieswith the versioned library nameContext
pg_textsearch uses Postgres shared memory (
ShmemInitStruct) for its index registry. Withoutshared_preload_libraries, each backend loads the .so independently viadlopen. If the .so file is replaced on disk (e.g., during a deployment) without restarting Postgres, different backends get different code, causing a fatalShmemIndex entry size is wrongerror. Requiringshared_preload_librariesensures all backends use the same .so (inherited from the postmaster via fork), eliminating this class of bugs.Testing
make format-checkpasses