Cut DB load: drop jobs realtime, remove dead index#395
Conversation
|
Updates to Preview Branch (perf/reduce-db-load) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR removes ChangesRealtime Job Updates to Adaptive Polling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@supabase/migrations/20260527224118_drop_dead_domain_hosts_index.sql`:
- Line 14: The migration contains a destructive step "DROP INDEX IF EXISTS
public.idx_domain_hosts_domain_id" which violates the additive-only policy;
instead remove the DROP INDEX statement from this migration and either (a)
convert it to a non-destructive, additive change (e.g., create a replacement
index or a no-op migration that records intent), or (b) move the DROP of
idx_domain_hosts_domain_id into an operational/manual maintenance playbook and
leave an in-repo comment or follow-up migration that gates the destructive step
after observation; update the migration to preserve only additive operations and
reference the index name idx_domain_hosts_domain_id and the DROP INDEX action in
the associated maintenance note.
In `@web/static/app/pages/webflow-jobs.js`:
- Around line 177-183: The scheduler currently fire-and-forgets onUpdate()
causing overlapping polls and unhandled rejections; change the setTimeout
callback in schedule() to an async function, await onUpdate() inside a try/catch
to handle errors, and call schedule() from a finally block so the next timer is
always scheduled (referencing schedule(), onUpdate(), timer, stopped, and
intervalMs()).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 40091654-7407-48ec-8943-0f4f478283b7
📒 Files selected for processing (4)
supabase/migrations/20260527224118_drop_dead_domain_hosts_index.sqlsupabase/migrations/20260527224119_disable_jobs_realtime.sqlweb/static/app/pages/dashboard.jsweb/static/app/pages/webflow-jobs.js
Release VersionsApp patch: ChangelogChanged
Removed
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
🐝 Review App Deployed Homepage: https://hover-pr-395.fly.dev |
Cut DB load: drop jobs realtime, remove dead index
Summary
Two low-risk database-load reductions, isolated from worker logic:
public.jobsfrom thesupabase_realtimepublication. Decoding the WAL for every job-counter tick (running_tasksbumps,recalculate_job_stats, theupdate_job_queue_counterstrigger) was ~14% of total DB time viarealtime.list_changes— billed continuously regardless of how many dashboards were subscribed. The frontend already polls the lane-isolated/v1/jobsAPI as a fallback, so this trades a constant tenant-wide cost for cheap, viewer-scoped polling.notificationsstays on the publication.subscribeToJobUpdatesnow polls (500 ms while a job is active, 1 s idle, re-evaluated each tick) instead of opening a now-dead Realtime channel. Both consuming paths already ran this way on staging where Realtime is unavailable. Removed the now-unused realtime constants and two dead imports.idx_domain_hosts_domain_idindex (0 scans; the composite(domain_id, host)unique index already serves everydomain_id-prefix lookup). Pure write overhead removed from everydomain_hostsupsert.Why
Under heavy job load the worker's adaptive DB-pressure controller pinned at its concurrency floor (
HOVER-JD) because query latency stayed above threshold. The Realtime WAL decode was a large, constant contributor to DB CPU contention; removing it lowers latency across the board. The hottest query (promote_waiting_with_outbox, ~58%) is intentionally left untouched — its per-call SQL is already optimal and the only lever is a riskier call-volume change, deferred pending re-measurement after this lands.Risk
Low. The publication change is reversible (
ALTER PUBLICATION supabase_realtime ADD TABLE public.jobs). The polling behaviour is already exercised on staging/preview. API polls hit the raw connection pool, not the pressure-controlled crawl lane, with 1–2 ms indexed queries.Test plan
jobsno longer inpg_publication_tablesandidx_domain_hosts_domain_idis gone/v1/jobspolling (500 ms active / 1 s idle) with no console errorsHOVER-JDfrequency andexec_ema_msdrop, andrealtime.list_changesfalls out of the toppg_stat_statementsentriesNeed help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit
Chores
Refactor
Documentation