Skip to content

Settings sweeps read by key, and the runs sweeps reach every run - #514

Merged
nambok merged 1 commit into
mainfrom
settings-scans-by-key
Nov 7, 2026
Merged

nambok merged 1 commit into
mainfrom
settings-scans-by-key

Conversation

@nambok

@nambok nambok commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Audit of every .scan() after the review sweeps were found reading none of the configs: their capped scan of the settings table stopped before reaching them. This fixes the other scans that read the whole settings table on a schedule, or that stop at a cap and can miss records.

Changes

  • New common::settings_index: an index partition INDEX#<name> in the settings table naming each record of one kind. Readers query it and get each record by key, drop members whose record is gone, and rebuild it from one fully paged scan when it was never built or is over a day old. Writers add the member when they save.
  • Automatic fixes (log_findings::teams_with_autofix, hourly): reads teams from the LOG_AUTOFIX index. Before, every run scanned the whole settings table. The gateway adds the team when the setting is saved.
  • Name check (hybrid_name_check::claims, every 15 minutes, hosted): reads reservations from the HYBRIDNAME index. The gateway adds the name when it is claimed.
  • PR outcomes (pr_outcomes::find_runs): the 20-page cap now saves where it stopped (SYSTEM / SCAN_CURSOR#<sweep>) and the next tick carries on from there; reaching the end starts over. Before, each tick restarted at page 1, so runs past page 20 were never reconciled. Each tick logs pages read, runs found and whether it reached the end.
  • Only team (hybrid_install::only_team): reads every page. It read one 50-item page of the teams table, which also holds ticket locks, so it could miss the team record or see only one of several teams.
Scan Table Can it miss records? Done
teams_with_autofix settings No (fully paged), but read the whole table hourly Index
hybrid_name_check::claims settings No (fully paged), but read the whole table every 15 min Index
pr_outcomes::find_runs runs Yes, past 20 pages (about 1,500 runs) Saved cursor
hybrid_install::only_team teams Yes, single 50-item page Fully paged
ready::sweep runs Only past 200 pages Left; far off
weekly_summary::run main Only past 40 pages, weekly Left
aws_permissions::accounts_by_team aws insights No, fully paged, small Left
email_settings::people users Only past 50 pages Left; small
setup_checks::setup_open users No, any one item Left
admin::scan_all users, teams, waitlist Large caps, platform admins only Left
sign_in::ensure_org teams No, fully paged Left

Verification

  • Tests: index rebuild timing and partition; index member extraction for both indexes; cursor steps (save at cap, clear at end, keep when filled); a multi-tick walk over a table larger than the cap reaching every page; cursor read back as the table key; only-team selection.
  • cargo test -p common --lib: 1,523 passed. cargo test -p worker pr_outcomes: 10 passed. cargo test -p worker name_index: 2 passed. cargo test -p gateway only_team: 2 passed.
  • cargo fmt and cargo clippy -p common -p gateway -p worker --all-targets -D warnings: clean.
  • The worker and gateway already have read and write on the settings table, which covers Query, BatchWriteItem and DeleteItem.

The settings table holds analytics, markers and every team's settings
together, well over 100,000 items on a busy install. Two sweeps found their
records by scanning all of it: the hourly automatic-fix sweep and the
15-minute name check. A shared index partition (INDEX#<name>) now names each
record; writers add to it, readers get each record by key, drop members whose
record is gone, and rebuild the index from one full scan at most once a day.

The PR-outcome sweeps scanned the runs table from the first page each tick
with a 20-page cap, so runs past the cap were never reached once the table
grew. They now save where the cap stopped and carry on from there.

The install's only-team lookup read one 50-item page of the teams table,
which also holds ticket locks; it now reads every page.
@nambok
nambok merged commit b86f732 into main Nov 7, 2026
10 checks passed
@nambok
nambok deleted the settings-scans-by-key branch November 7, 2026 18:08
coderhelm Bot pushed a commit that referenced this pull request Dec 3, 2026
Moves dashboardRef from 6593784 to 1002bc7, carrying CoderHelm/coderhelm #502, #514, #513, #527, #530, #531, #533, #529, #536, #535, #499 and #537.
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.

1 participant