Social Starred list is an unbounded GET-per-record scan #65
Labels
No labels
actions
bug
cli
duplicate
enhancement
fork
forum
git storage
help wanted
insights
invalid
issues
moderation
oidc
ownership transfer
packages
pr/merge protection rules
projects
pull requests
question
releases
sponsorships
tags
webhooks
wiki
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
crueber/walhub#65
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up from the backend audit on issue #59 (origin/main @
940ca8c).Evidence: internal/social/service.go:168-230. Starred() LISTs the user's whole starred prefix (line 189) and GETs every record (lines 196-217), then truncates to the page (lines 224-228). Cost is O(total stars) GETs per page load with no backend bound (only the output is clamped to ListMaxPage).
Impact: a user with e.g. 10k stars costs ~10k GETs per tray page. Only unbounded read found in the Q3 sweep; everything else is O(1) or bounded-O(n).
Suggested fix: bound the backend scan with a documented truncation, or add a time-ordered per-user index so pagination does not need a full scan (keys are repo-keyed, not time-ordered, so server-side paging needs a new shape).
Fix open in PR #68 (branch fix/issue-65): Starred() is now keyset pagination over the key space (repo ascending) — 1 LIST from the after key aborted at the page edge, at most n+1 GETs + n+1 HEADs per page, flat in the total; skip-on-error preserved; no reverse index / users LIST / global scan. Evidence: page-1 cost identical at 60 and 600 stars. Sibling surfaces audited (watching, tray, releases list, fan-out) — all already bounded, no change. One note: TestStarConcurrentConverge flakes on unmodified main too (pre-existing, unrelated).
PR #68 review (branch fix/issue-65, commit
60c3d63) — verified in scratch worktree, main worktree untouched.PASS (all with file:line):
Tests (scratch worktree @
60c3d63): targeted Starred/evidence/cover/HTTP suites all PASS with -race; package coverage 99.2% (>=95% gate); gofmt clean; go vet clean.PRE-EXISTING FLAKE (not this PR, not fixed): TestStarConcurrentConverge (service_test.go:55-77) fails intermittently (counts 3/4/8/9 vs want 2) with and without -race load; reproduces on base
87d9c2bin a separate scratch worktree, and the Star/bump path is byte-identical between base and PR. Suggest a separate issue for the Star check-then-act race; full suite passed once (1.049s ok) so it is scheduling-dependent.No fixes pushed (nothing PR-caused to fix). MERGE RECOMMENDATION: ready to merge.
Fixed by PR #68 (review clean; keyset pagination, O(page) pinned; 99.2% coverage), merged. Closing.