Queries fail while the vamana worker loads a large index, because the worker stops sending heartbeats during the load
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start with vamanaworker.c around lines 1394 and 1851, then trace the index load path and VamanaWorkerWaitUntilAvailable() behavior. Reproduce with an index that takes more than three seconds to load and inspect how heartbeat age and svs.worker_startup_timeout_ms affect the second query. Done means queries wait through a live worker's load, and the worker state reports loading if that recommendation is included.
Written by the indexing model from the issue text.
Description
Problem
After a server restart, the vamana worker loads an index from disk the first time it is queried. The load runs synchronously inside the worker's main loop, and the heartbeat is only written at the top of that loop (vamanaworker.c ~line 1394), so no heartbeat is written for the duration of the load.
Before waiting for the worker, VamanaWorkerWaitUntilAvailable() checks the heartbeat. If the heartbeat is older than VAMANA_HEARTBEAT_STALE_MS (3000 ms, hard-coded), it raises an error immediately instead of waiting (vamanaworker.c ~line 1851). The worker is alive and busy, but backends treat it as hung.
As a result, any index whose load takes more than about 3 seconds is unavailable for the whole load:
- Queries that arrive more than ~3 s after the load starts fail immediately with "vamana background worker unavailable … the worker's last heartbeat is older than 3000 ms".
- Queries that arrive in the first ~3 s wait, but only up to
svs.worker_startup_timeout_ms, and fail if the load takes longer.
svs.worker_startup_timeout_ms therefore doesn't help: the stale-heartbeat check fails a query before it ever reaches the wait. Large indexes easily take longer than 3 s to load.
Steps to reproduce
- Build a vamana index large enough that loading it takes more than a few seconds.
- Restart the server.
- Send one query against the index to trigger the load.
- While the load is still running, more than 3 s after it started, send another query from a different session.
The second query fails immediately with the stale-heartbeat error, and pg_stat_vamana_worker reports worker_state = 'unresponsive' until the load finishes. Once loaded, the index serves queries normally.
Environment: SVS-Extension-for-PostgreSQL 033cd2c, SVS C API 0.5.0, PostgreSQL 18.6.
Recommendations
- Keep the heartbeat alive during long operations. Update it periodically while an index loads, e.g. from the load path, or run the load outside the heartbeat loop.
- Don't treat "stale heartbeat, live worker" as fatal. If the worker's process is alive, keep waiting up to
svs.worker_startup_timeout_ms, and reserve the immediate error for a worker that has exited. - Report the loading state. Show it in
pg_stat_vamana_worker(e.g.worker_state = 'loading'), so clients and monitoring can tell a busy worker from a hung one.
- Dominant language
- Perl
- Stars
- 3
- Forks
- 3
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 5
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from intel/SVS-Extension-for-PostgreSQL
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 3/5 1-2 days Newbie friendliness 66/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 46/100
-
PostgreSQL 18.6+ requires `svs` in `output_plugin_libraries`, but this isn't documented or checkedOpen
Difficulty 4/5 3-5 days Newbie friendliness 48/100
All issues in intel/SVS-Extension-for-PostgreSQL
Similar issues
-
fix(rodex): sent mail loses the last character of title and bodyPossibly taken @baphomello claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
owasp-modsecurity/ModSecurity-nginx#418 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
inverse-inc/packetfence#9768 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
metacpan/metacpan-api#1534 ·