`cpu_governance` regression test fails intermittently: the published thread count is not updated within its 30 second wait

Open
#109 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
46/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c, postgresql
Domain
backend, testing

Research direction

Start with test/sql/cpu_governance.sql and inspect how its notification and polling assertions interact with the launcher and worker code. Reproduce the intermittent failure on unmodified main and capture logs around listener startup, the catalog update, and index rebuilds. Done means identifying the cause and making the grant update reliably visible within the test's wait, with the regression test passing.

Written by the indexing model from the issue text.

Description

bug

Summary

test/sql/cpu_governance.sql fails on a fraction of runs on unmodified main. When it fails, the check that follows its wait loop reports desired_ok and reserved_ok as f instead of t, and the file takes about 87 seconds instead of about 10. The columns still show the previous configuration rather than wrong values, so this looks like a timing problem in when the launcher publishes a changed grant, or in the test's assumption about when it does.

What the test does

After restoring svs.search_num_threads, the test changes the database's row:

UPDATE vamana_databases SET search_num_threads = 6, search_threads_reserved = 2
	WHERE datname = current_database();

and then polls pg_stat_vamana_worker for up to 30 seconds (300 iterations of pg_sleep(0.1)) until search_threads_desired = 6. The comment above the UPDATE says the catalog change fires the vamana_databases_changed notification, which wakes the launcher promptly instead of waiting out its 180 second naptime (VAMANA_LAUNCHER_NAPTIME_MS). In a failing run the loop times out, so the assertion that follows sees the old values:

-  t          | t           | t                  | t
+  f          | f           | t                  | t

How often

Running only this file repeatedly against a freshly restarted server:

  • Unmodified main at 033cd2c: 2 failures in 12 runs.
  • A branch containing main plus unrelated changes to the save and load path: 4 failures in 10 runs, and 1 in 4 with those changes reverted.

Passing runs take 10 to 27 seconds; every failing run took 86 to 87 seconds. The small samples cannot distinguish the failure rate between these code versions. I have only seen this on a large multi-core Linux server (Ubuntu 22.04, PostgreSQL 18.1, SVS prebuilt library). I have not looked for it in CI.

What the server log shows

I only kept a server log from a failing run on the branch above, not from main. Timestamps are from one failing run; contrib_regression is the regression database:

10:07:44.596  vamana launcher started
10:07:44.610  vamana background worker started for database "contrib_regression"
10:07:44.693  parameter "svs.search_num_threads" changed to "0"
10:07:44.696  vamana worker: reloading index <oid>
10:07:44.700  vamana worker: no saved copy for index <oid>, rebuilding
10:07:44.704  parameter "svs.search_num_threads" changed to "8"
10:07:44.721  vamana worker: reloading index <oid>
10:07:44.722  vamana worker: no saved copy for index <oid>, rebuilding
10:07:44.722  rebuilding vamana index from table data
10:07:59.805  vamana worker: reloading index <oid>
10:07:59.805  vamana worker: no saved copy for index <oid>, rebuilding
10:07:59.805  rebuilding vamana index from table data
              (nothing logged by the worker for about 60 seconds)
10:09:01.142  background worker "vamana worker" exited with exit code 1

So the worker is reloading and rebuilding the index repeatedly while svs.search_num_threads is changed twice in quick succession (0, then back to 8) and the UPDATE runs, and then goes quiet. The test's polling window ends during that quiet period. The sequence begins about 100 ms after the launcher itself started, which is also when the test begins its first statements.

What I do not know

I have not established the cause. Candidates, none confirmed:

  • The NOTIFY for the UPDATE arrives before the launcher has started listening, so the launcher only reconciles at its next scheduled pass.
  • The launcher or worker is busy with the rebuild triggered by the earlier setting changes when the UPDATE arrives, and publishes the new grant later than 30 seconds.
  • The 30 second wait is simply too short for a rebuild that takes about 15 seconds on its own.

Suggested next steps

  1. Capture the server log from a failing run on unmodified main to confirm the same stall, and log when the launcher begins listening relative to the test's first UPDATE.
  2. Decide whether the fix belongs in the launcher (wake-up reliability) or in the test (wait for the rebuild to finish before changing the row, or wait longer).
Dominant language
Perl
Stars
3
Forks
3
Avg merge
4d 19h
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from intel/SVS-Extension-for-PostgreSQL

All issues in intel/SVS-Extension-for-PostgreSQL

Similar issues

More Perl issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.