Skip to content

ref(crons): Remove monitor from the check-in model - #127646

Merged
wedamija merged 2 commits into
masterfrom
danf/crons-checkin-monitor-id-2-remove-model
Oct 16, 2026
Merged

wedamija merged 2 commits into
masterfrom
danf/crons-checkin-monitor-id-2-remove-model

Conversation

@wedamija

@wedamija wedamija commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Part of a series reducing crons database work per check-in, as check-in volume grows.

Removes monitor from the MonitorCheckIn model along with its two indexes, (monitor, date_added, status) (~75 GB) and (monitor, status, date_added) (~59 GB). The migration drops the indexes with DROP INDEX CONCURRENTLY and uses SafeRemoveField with MOVE_TO_PENDING, so the column stays until the next PR.

Do not merge until #127644 has deployed.

@wedamija
wedamija requested review from a team as code owners October 15, 2026 20:56
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/monitors/migrations/0020_make_checkin_monitor_nullable.py src/sentry/monitors/migrations/0021_remove_checkin_monitor.py

for 0020_make_checkin_monitor_nullable in monitors

--
-- Alter field monitor on monitorcheckin
--
SET CONSTRAINTS "sentry_monitorcheckin_monitor_id_c15ff0f0_fk_sentry_monitor_id" IMMEDIATE; ALTER TABLE "sentry_monitorcheckin" DROP CONSTRAINT "sentry_monitorcheckin_monitor_id_c15ff0f0_fk_sentry_monitor_id";
ALTER TABLE "sentry_monitorcheckin" ALTER COLUMN "monitor_id" DROP NOT NULL;

for 0021_remove_checkin_monitor in monitors

--
-- Remove index sentry_moni_monitor_0a49ce_idx from monitorcheckin
--
DROP INDEX CONCURRENTLY IF EXISTS "sentry_moni_monitor_0a49ce_idx";
--
-- Remove index sentry_moni_monitor_7ed5ce_idx from monitorcheckin
--
DROP INDEX CONCURRENTLY IF EXISTS "sentry_moni_monitor_7ed5ce_idx";
--
-- Moved monitorcheckin.monitor field to pending deletion state
--
-- (no-op)

@wedamija
wedamija force-pushed the danf/crons-checkin-monitor-id-2-remove-model branch from f03dfbf to aacd7de Compare October 15, 2026 21:45
@wedamija
wedamija force-pushed the danf/crons-checkin-monitor-id-1-stop-using branch from 15ba4bd to 8c4eb95 Compare October 15, 2026 21:45
@sentry

sentry Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 630 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

@github-actions

Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/monitors/migrations/0021_make_checkin_monitor_nullable.py src/sentry/monitors/migrations/0022_remove_checkin_monitor.py

for 0021_make_checkin_monitor_nullable in monitors

--
-- Alter field monitor on monitorcheckin
--
SET CONSTRAINTS "sentry_monitorcheckin_monitor_id_c15ff0f0_fk_sentry_monitor_id" IMMEDIATE; ALTER TABLE "sentry_monitorcheckin" DROP CONSTRAINT "sentry_monitorcheckin_monitor_id_c15ff0f0_fk_sentry_monitor_id";
ALTER TABLE "sentry_monitorcheckin" ALTER COLUMN "monitor_id" DROP NOT NULL;

for 0022_remove_checkin_monitor in monitors

--
-- Remove index sentry_moni_monitor_0a49ce_idx from monitorcheckin
--
DROP INDEX CONCURRENTLY IF EXISTS "sentry_moni_monitor_0a49ce_idx";
--
-- Remove index sentry_moni_monitor_7ed5ce_idx from monitorcheckin
--
DROP INDEX CONCURRENTLY IF EXISTS "sentry_moni_monitor_7ed5ce_idx";
--
-- Moved monitorcheckin.monitor field to pending deletion state
--
-- (no-op)

@wedamija
wedamija force-pushed the danf/crons-checkin-monitor-id-1-stop-using branch from 93b8891 to bb5f681 Compare October 15, 2026 22:24
@wedamija
wedamija requested a review from a team as a code owner October 15, 2026 22:24
@wedamija
wedamija force-pushed the danf/crons-checkin-monitor-id-2-remove-model branch from cbcb40b to c28d830 Compare October 15, 2026 22:24
Base automatically changed from danf/crons-checkin-monitor-id-1-stop-using to master October 15, 2026 22:46
@wedamija
wedamija force-pushed the danf/crons-checkin-monitor-id-2-remove-model branch from c28d830 to 1c90d7b Compare October 15, 2026 22:51
@github-actions

Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/monitors/migrations/0022_remove_checkin_monitor.py

for 0022_remove_checkin_monitor in monitors

--
-- Remove index sentry_moni_monitor_0a49ce_idx from monitorcheckin
--
DROP INDEX CONCURRENTLY IF EXISTS "sentry_moni_monitor_0a49ce_idx";
--
-- Remove index sentry_moni_monitor_7ed5ce_idx from monitorcheckin
--
DROP INDEX CONCURRENTLY IF EXISTS "sentry_moni_monitor_7ed5ce_idx";
--
-- Moved monitorcheckin.monitor field to pending deletion state
--
-- (no-op)

Part of a series reducing crons database work per check-in, as check-in
volume grows.

Removes `monitor` from the `MonitorCheckIn` model along with its two
indexes, `(monitor, date_added, status)` (~75 GB) and `(monitor, status,
date_added)` (~59 GB). The migration drops the indexes concurrently and
uses `SafeRemoveField` with `MOVE_TO_PENDING`, so the column stays until
the next PR. It is post-deployment because of the index sizes.

Co-Authored-By: Claude <noreply@anthropic.com>
@wedamija
wedamija force-pushed the danf/crons-checkin-monitor-id-2-remove-model branch from 1c90d7b to c4aabd8 Compare October 15, 2026 23:07
DROP INDEX CONCURRENTLY does not scan the table, so this does not
need to be a post-deployment migration.

Co-Authored-By: Claude <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9e329c3. Configure here.

# is a schema change, it's completely safe to run the operation after the code has deployed.
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment

is_post_deployment = False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Index drop not marked post-deployment

Medium Severity

Setting is_post_deployment to False makes this migration run automatically during deploy. The two unused monitor indexes on MonitorCheckIn are about 75 GB and 59 GB, so dropping them inline can stall or fail the deploy instead of being applied later through the post-deployment path.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9e329c3. Configure here.

@wedamija
wedamija merged commit fdada24 into master Oct 16, 2026
91 checks passed
@wedamija
wedamija deleted the danf/crons-checkin-monitor-id-2-remove-model branch October 16, 2026 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants