Skip to content

fix(rc-entitlement-drift-check): extend cron pg_net timeout to 60s#70

Merged
Patchalv merged 1 commit into
mainfrom
followup-49-cron-pg-net-timeout
May 13, 2026
Merged

fix(rc-entitlement-drift-check): extend cron pg_net timeout to 60s#70
Patchalv merged 1 commit into
mainfrom
followup-49-cron-pg-net-timeout

Conversation

@Patchalv

Copy link
Copy Markdown
Owner

Observability follow-up to #60 / #66 / #68.

Summary

The drift check function takes ~30 seconds with the current profile count because per-customer RC fetches are sequential, but the cron migration's `net.http_post` call uses pg_net's default 5-second timeout. The function ran to completion on every fire (Sentry events, heartbeat logs all worked) but `net._http_response.status_code` was always recorded as `NULL` for cron-triggered runs, making the cron's success state invisible from SQL.

This migration uses `cron.alter_job` to replace just the command text on the existing scheduled job, keeping the schedule, jobid, and lock-table behavior identical. Function behavior is unchanged.

How this surfaced

During the first real smoke test of #68:

  • `request_id 37` (default 5s timeout): `status_code: null` — pg_net gave up, function still ran.
  • `request_id 38` (explicit 60s timeout): `status_code: 200, content: '{"drift_count":0}'` — pg_net captured the actual response.

The fix is to make cron behave like request 38.

Test plan

After merging:

  • `git pull && supabase db push`

  • In the SQL editor, confirm the cron command was updated:

    \`\`\`sql
    select jobname, schedule, command from cron.job
    where jobname = 'rc-entitlement-drift-check';
    \`\`\`
    
    Command should now include \`timeout_milliseconds := 60000\`.
    
  • Wait for the next `:17 mod 6h` UTC scheduled fire, then check:

    \`\`\`sql
    select id, status_code, content, created from net._http_response
    order by created desc limit 3;
    \`\`\`
    
    The row from the cron fire should show \`status_code: 200\` and \`content: '{\"drift_count\":N}'\`. Previously these rows showed \`status_code: null\`.
    

Follow-up

None.

The drift check runs ~30s with the current profile count (sequential
per-customer RC fetches), which exceeds pg_net's default 5s timeout.
The function itself completed correctly on every fire — Sentry events
fired, heartbeats logged — but net._http_response.status_code stayed
NULL for cron-triggered runs, making the cron's success/failure invisible
in pg_net's response table.

Uses cron.alter_job to replace just the command text on the existing
jobid; schedule and lock-table behavior are unchanged.

Surfaced during the first real smoke test of PR #68's per-profile-fetch
refactor — the manual invocation at request_id=37 hit the 5s timeout
even though the function ran to completion, while request_id=38 with
an explicit 60s pg_net timeout returned status_code=200 correctly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Patchalv has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 1 second before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 100ce968-086a-45f0-9098-b286c4eaafcb

📥 Commits

Reviewing files that changed from the base of the PR and between c09a826 and f60147b.

📒 Files selected for processing (1)
  • supabase/migrations/20260513000003_extend_drift_check_pg_net_timeout.sql

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Patchalv Patchalv merged commit 2e3f896 into main May 13, 2026
1 check passed
@Patchalv Patchalv deleted the followup-49-cron-pg-net-timeout branch May 13, 2026 21:08
Patchalv added a commit that referenced this pull request May 13, 2026
)

- Build command was iOS-only; reality is `eas build --platform <ios|android>` plus the `npm run build:*` aliases.
- Architecture line listed payments as iOS-only; the app supports Google Play Billing too (see docs/payments.md).
- Removed reference to docs/technical-plan.md — file doesn't exist.
- Added drift_check_runs to the table quick-reference.
- Added a one-liner under IMPORTANT documenting the pg_cron + supabase_vault pattern introduced in #60/#68/#70, so future work follows the same shape instead of re-deriving it.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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