Skip to content

[#31649] YSQL: Preload pgvector to keep hnsw.ef_search across extension load#31650

Closed
hari90 wants to merge 1 commit into
yugabyte:masterfrom
hari90:PgVectorLoad
Closed

[#31649] YSQL: Preload pgvector to keep hnsw.ef_search across extension load#31650
hari90 wants to merge 1 commit into
yugabyte:masterfrom
hari90:PgVectorLoad

Conversation

@hari90
Copy link
Copy Markdown
Contributor

@hari90 hari90 commented May 14, 2026

Summary

Add the pgvector shared library (vector) to the default shared_preload_libraries assembled in pg_wrapper.cc. Previously the library was loaded on demand the first time a backend executed a vector operation, and the placeholder-promotion path for the extension's custom GUCs failed to preserve user-supplied values — SET hnsw.ef_search = 999 issued before the first vector query was silently reset to the default (40) once the library loaded.

Preloading the library at postmaster start registers hnsw.ef_search / ybhnsw.ef_search in every backend up front, so SET no longer takes the placeholder path and the user's value survives into the first vector query.

Fixes #31649.

Test plan

  • Manual repro (single-node release cluster from this branch):
    • Session 1: CREATE EXTENSION vector, create ef_repro(id, embedding vector(3)), insert 200 random rows, build ybhnsw index.
    • Session 2 (fresh backend): SET hnsw.ef_search = 999; then run a vector query that triggers extension load. SHOW hnsw.ef_search returns 999 (was 40 before this change). SHOW ybhnsw.ef_search returns 999 as well.
    • Confirmed SHOW shared_preload_libraries; includes vector.

CSI

… extension load

Summary:
Add the pgvector shared library ("vector") to the default
shared_preload_libraries set assembled in pg_wrapper.cc. Previously the
library was loaded on-demand the first time a backend executed a vector
operation. Custom GUCs registered by the extension (notably
hnsw.ef_search / ybhnsw.ef_search) went through the placeholder
promotion path on load, and the value a user had set via SET before the
first vector operation was reset to the default (40) instead of being
preserved.

Preloading the library at postmaster start registers the GUCs in every
backend up front, so SET no longer goes through the placeholder path
and user-supplied values survive into the first vector query.

Test Plan:
Manual repro (single-node release cluster from this branch):

Session 1:
  CREATE EXTENSION IF NOT EXISTS vector;
  CREATE TABLE ef_repro (id bigserial PRIMARY KEY, embedding vector(3))
      SPLIT INTO 1 TABLETS;
  INSERT 200 rows with random vector(3) values;
  CREATE INDEX ef_repro_idx ON ef_repro USING ybhnsw (embedding vector_l2_ops);

Session 2 (fresh backend):
  SET hnsw.ef_search = 999;
  SHOW hnsw.ef_search;         -- 999
  SELECT id FROM ef_repro ORDER BY embedding <-> '[0,0,0]' LIMIT 1;
  SHOW hnsw.ef_search;         -- 999 (was 40 before this change)
  SHOW ybhnsw.ef_search;       -- 999 (was 40 before this change)

Also confirmed shared_preload_libraries contains "vector" via
SHOW shared_preload_libraries.

---
_automated · Claude Code (Opus 4.7)_
@netlify
Copy link
Copy Markdown

netlify Bot commented May 14, 2026

Deploy Preview for infallible-bardeen-164bc9 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 09d397c
🔍 Latest deploy log https://app.netlify.com/projects/infallible-bardeen-164bc9/deploys/6a06199ef2de610008767ec0
😎 Deploy Preview https://deploy-preview-31650--infallible-bardeen-164bc9.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds the "vector" library to the list of metrics libraries in the Postgres configuration within pg_wrapper.cc. I have no feedback to provide.

@hari90
Copy link
Copy Markdown
Contributor Author

hari90 commented May 14, 2026

trigger jenkins

@hari90
Copy link
Copy Markdown
Contributor Author

hari90 commented May 14, 2026

Jenkins build has been triggered. Results will be posted once it completes. CSI


JenkinsBot

@hari90
Copy link
Copy Markdown
Contributor Author

hari90 commented May 15, 2026

Jenkins build for commit 09d397c2: Fail
CSI
Reason: CSI status: WARNING

Exceptions:


🔨 DB Build/Test Job Summary

Build Total Passed Failed Failed After Retries
PR31650-alma8-clang21-tsan 9299 7660 19 13
PR31650-alma8-clang21-release 2 1 1 1
PR31650-mac14-clang21-release 2 2 0 0
PR31650-alma8-gcc12-fastdebug 9511 9075 10 4
PR31650-alma9-clang21-asan 9394 8681 22 10
PR31650-ubuntu22.04-clang21-debug 2 2 0 0
PR31650-arm-alma8-clang21-release 9492 9117 8 3
PR31650-arm-mac14-clang21-release 17 17 0 0

JenkinsBot

1 similar comment
@hari90
Copy link
Copy Markdown
Contributor Author

hari90 commented May 15, 2026

Jenkins build for commit 09d397c2: Fail
CSI
Reason: CSI status: WARNING

Exceptions:


🔨 DB Build/Test Job Summary

Build Total Passed Failed Failed After Retries
PR31650-alma8-clang21-tsan 9299 7660 19 13
PR31650-alma8-clang21-release 2 1 1 1
PR31650-mac14-clang21-release 2 2 0 0
PR31650-alma8-gcc12-fastdebug 9511 9075 10 4
PR31650-alma9-clang21-asan 9394 8681 22 10
PR31650-ubuntu22.04-clang21-debug 2 2 0 0
PR31650-arm-alma8-clang21-release 9492 9117 8 3
PR31650-arm-mac14-clang21-release 17 17 0 0

JenkinsBot

@hari90
Copy link
Copy Markdown
Contributor Author

hari90 commented May 18, 2026

Trigger Jenkins

@hari90
Copy link
Copy Markdown
Contributor Author

hari90 commented May 18, 2026

Jenkins build for commit 09d397c2: Pass
CSI

Passed: 12


🔨 DB Build/Test Job Summary

Build Total Passed Failed Failed After Retries
PR31650-alma8-clang21-tsan 9299 7660 19 13
PR31650-alma8-clang21-release 9497 9124 12 4
PR31650-mac14-clang21-release 2 2 0 0
PR31650-alma8-gcc12-fastdebug 9511 9075 10 4
PR31650-alma9-clang21-asan 9394 8681 22 10
PR31650-ubuntu22.04-clang21-debug 2 2 0 0
PR31650-arm-alma8-clang21-release 9492 9117 8 3
PR31650-arm-mac14-clang21-release 17 17 0 0

JenkinsBot

@jasonyb
Copy link
Copy Markdown
Contributor

jasonyb commented May 18, 2026

Superseded by #31677

@hari90 hari90 closed this May 19, 2026
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.

YSQL: hnsw.ef_search GUC reset to default when pgvector library loads on demand

2 participants