Repository navigation
Traffic retention job + cheaper actions observer - #419
Merged
Merged
Conversation
Signed-off-by: mfwolffe <wolffemf@dukes.jmu.edu>
Signed-off-by: mfwolffe <wolffemf@dukes.jmu.edu>
Signed-off-by: mfwolffe <wolffemf@dukes.jmu.edu>
Signed-off-by: mfwolffe <wolffemf@dukes.jmu.edu>
Signed-off-by: mfwolffe <wolffemf@dukes.jmu.edu>
Signed-off-by: mfwolffe <wolffemf@dukes.jmu.edu>
Signed-off-by: mfwolffe <wolffemf@dukes.jmu.edu>
Signed-off-by: mfwolffe <wolffemf@dukes.jmu.edu>
Signed-off-by: mfwolffe <wolffemf@dukes.jmu.edu>
Signed-off-by: mfwolffe <wolffemf@dukes.jmu.edu>
mfwolffe
force-pushed
the
perf/traffic-retention
branch
from
September 2, 2026 06:52
2546f7f to
6acd7fa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 3 leftovers from
docs/internal/retro/2026-09-02-availability-sitrep.md(root causes #7 and #10).
Traffic retention (#7)
repo_traffic_*had no purge since 2026-05-18: 881 MB of a 988 MB prod DB,~30k rows/day/table, mostly crawler paths. The Traffic UI reads 14 days.
ccb1172f+6acd7fa0— 0129:repo_traffic_paths_day_idx,repo_traffic_referrers_day_idx,CONCURRENTLY+NO TRANSACTION(both tables are written synchronously inthe request path).
repo_traffic_uniquesreuses its existingcreated_atindex instead of getting a second one;
repo_traffic_dailyalready had(day DESC). No bulk DELETE in the migration on purpose.c178a8c4— four:execrowsbatched deletes ininternal/repos/queries/repo_traffic.sql,WHERE ctid IN (SELECT ctid ... LIMIT $2);make sqlc-generateoutput included.fe6cf73a—traffic.Purge: 30-day window for_uniques/_paths/_referrers,400 days for
_daily. 5k rows per statement, each its own transaction,capped at 2000 batches per table per run.
1eccf91d—traffic:purgehandler; payload overrides the windows and bounds.Idempotent: the cutoff is recomputed per run and rows inside the window are
never touched. Re-enqueues itself when it stops on the batch cap so the
backlog drains in one night rather than over 480 cron beats.
ed912f8a— registered incmd/shithubd/worker.go,ExecStartadded toshithubd-cron.service.Decisions: 30 days rather than the sitrep's 14 so a purge can never truncate a
bar the chart draws;
_dailykept at 400 days (one row per repo per day — it isthe only long-term history and is small); the 2.5M-row backfill is the job's
first run, not a migration, so no deploy holds a long transaction.
actionsobserver (#10)
27d5ba92—sum(octet_length(chunk))over the hot log-chunk table (a fullscan + detoast, independent of traffic) moved off the 15 s tick onto its own
5 min cadence. Count and queue-depth gauges are unchanged at 15 s. Metric
names unchanged.
42be95b8— the 5 min lag noted in the two runbooks that list the gauge.Tests
make cilocally (golangci-lint 2.13.2, gofumpt, policy/markdown/secret-log/spdx/migration/systemd lints, unit tests, build)
internal/repos/trafficunit — batch loop bounds: short batch, exactmultiple,
MaxBatchescap, non-positive bounds, partial progress onerror, canceled context, option normalization, retention > UI window
internal/infra/metricsunit — tick ratio, slow refresh every N ticks,cancel, clamp (interval injected, no DB)
rebase onto trunk
3c9e1dcd— every step green, zero FAIL lines.TestTrafficPurgeKeepsTheRetentionWindow(30-day boundary kept, olderrow dropped,
_dailyon its own 400-day window, second run a no-op) andTestTrafficPurgeBoundsDeletesPerRun(BatchSize×MaxBatchescap,second pass resumes) both pass;
internal/worker/jobs,internal/repos/traffic,internal/infra/metricsandinternal/migrationsfsallok.(
6acd7fa0), migration-version lint green.6f36eda1fixed the one real miss an earlier run caught:assertTrafficDaysexpected days in the wrong order against
ORDER BY day ASC. The purge hadkept exactly the right rows.