Skip to content

Fix svs.max_build_memory initializer mismatch - #57

Merged
matt-welch merged 1 commit into
mainfrom
cassert-is175-standby02
Oct 1, 2026
Merged

matt-welch merged 1 commit into
mainfrom
cassert-is175-standby02

Conversation

@matt-welch

Copy link
Copy Markdown
Contributor

Description

svs.max_build_memory's GUC registration (src/vamana.c) sets a boot_val of 4096 MB, but the C variable backing it (src/svs_memory.c) initialized to 100. On a build with --enable-cassert, PostgreSQL's GUC consistency check requires a custom variable's initial value to be either 0 or exactly equal to its registered boot_val; since this variable started at 100, neither held, and every backend that loads svs crashed immediately on startup, before any GUC even took effect. Release builds were never affected: DefineCustomIntVariable unconditionally overwrites the C variable with boot_val at registration time regardless of build type, so the stale 100 was dead code there, never observed by anything at runtime. test/expected/runtime_params.out already asserts 4096 as the correct default, and that test already passed before this change, confirming the fix brings the initializer in line with what the GUC registration, the regression suite, and runtime behavior already agreed on. This is a one-line change: the initializer in src/svs_memory.c moves from 100 to 4096. No release-build behavior changes.

Related Issues

None.

Type of Change

  • Bug fix
  • New feature
  • Refactor / code cleanup
  • Documentation update
  • Test addition or update
  • Build / CI change

Pre-Merge Checklist

Build

  • make completes without errors or warnings
  • make install completes successfully

Tests

  • If this PR introduces no new behavior: existing regression tests (make installcheck) and TAP tests (test/t/) pass with no failures
  • If this PR introduces new behavior: test cases covering it were added to test/sql/ and/or test/t/
  • If this PR adds a standalone unit-test module under test/modules/: it builds and passes (make -C test/modules/<module> installcheck)

Documentation

  • Relevant docs under docs/ updated if architecture or usage changed

Testing Notes

Full clean build (make clean && make -j$(nproc) && make install) completed with no errors. One pre-existing compiler warning appears during the build (ISO C90 forbids mixed declarations and code in the SVS library's own svs/c/svs_c.h header), but it is unrelated to this change, present in a third-party header this PR does not touch, and not newly introduced by this one-line edit. Full TAP suite (make prove_installcheck): 47 files, 1186 tests, all passing, with one expected skip (18_build_offset_overflow.pl, gated behind enable_slow_tests=yes and not run by default). Full SQL regression suite (test_svs_ext_regression.sh): 7 of 7 test files passing, including runtime_params, which directly asserts that SHOW svs.max_build_memory reads 4096. Also independently confirmed by reading PostgreSQL's own GUC implementation (src/backend/utils/misc/guc.c) that the consistency check this fixes is compiled out entirely without --enable-cassert, and that GUC registration always sets the backing C variable to boot_val regardless of build type, so this change has no observable effect on a normal (non-assert) build. The other four GUC initializers declared in the same file (vamana_max_residency_memory_mb, vamana_default_residency_memory_mb, vamana_max_search_work_mem_mb, vamana_default_search_work_mem_mb) were checked against their own registered boot_vals and already match; none needed a change.

svs.max_build_memory's GUC registration sets a boot value of 4096 MB,
but the C variable backing it initialized to 100. On a debug-assertion
build, PostgreSQL's GUC-consistency check requires the two to match, so
any such build crashes on startup as soon as the extension loads, before
any GUC even has a chance to take effect.

Release builds were never affected: GUC registration unconditionally
overwrites the C variable with the boot value at startup, so the stale
100 was dead code there. The regression suite's expected output already
asserts 4096 as the default, confirming the change brings the
initializer in line with behavior the test suite, the GUC registration,
and runtime output already agreed on.

- Change the initializer in src/svs_memory.c from 100 to 4096 to match
  the boot_val already registered for this GUC
- No behavior change on a normal build; this only matters for builds
  with assertions enabled

Signed-off-by: Matt Welch <matt.welch@intel.com>
@matt-welch
matt-welch requested a review from a team October 1, 2026 18:49

@asonje asonje left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matt-welch
matt-welch merged commit ef8e7ee into main Oct 1, 2026
5 checks passed
@matt-welch
matt-welch deleted the cassert-is175-standby02 branch October 1, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants