Repository navigation
feat(sourcemaps): Backfill and index has_debug_ids on project artifact bundles - #130424
Conversation
wedamija
left a comment
There was a problem hiding this comment.
This table has around 100m rows. It'll probably take a while to process this, but I think it should be able to run successfully.
4e63fd3 to
ffce04c
Compare
The stack changed: has_debug_ids moved from ArtifactBundle to ProjectArtifactBundle with a partial index on project_id, and the PRs are rebased on master. Please review again.
Sentry Snapshot Testing
|
61b8ad7 to
2c8f0b6
Compare
|
I'm adding a getsentry custom job that we'll run in the large regions instead of the migration. |
5805a1c to
1e99a0f
Compare
|
This PR has a migration; here is the generated SQL for for --
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQLfor --
-- Create index sentry_pab_project_debug_idx on field(s) project_id of model projectartifactbundle
--
CREATE INDEX CONCURRENTLY "sentry_pab_project_debug_idx" ON "sentry_projectartifactbundle" ("project_id") WHERE "has_debug_ids"; |
622a4bb to
596f9c8
Compare
596f9c8 to
a018f0c
Compare
Sets the flag on every ProjectArtifactBundle whose bundle has DebugIdArtifactBundle rows. Links created since the write path deployed already have it, so this has to run after that change is deployed. Co-Authored-By: Jan Michael Auer <[email protected]> Co-Authored-By: Lorenzo Cian <[email protected]>
Adds a partial index on ProjectArtifactBundle.project_id that holds only the links with has_debug_ids set. Checking whether a project has any such link becomes one index lookup, whether or not the project has one. The table is large, so this is a post-deployment migration and the index is created concurrently. It runs after the backfill so that the backfill does not also have to update the index. Co-Authored-By: Jan Michael Auer <[email protected]> Co-Authored-By: Lorenzo Cian <[email protected]>
Each batch now reads only the id 10k links ahead and updates the id range up to it. That keeps batches full where ids are sparse, replaces the IN list of 1k ids with one range scan on the primary key, and drops the transfer of the ids through Python. The literal bounds keep the planner on index probes into the debug-ID rows. Co-Authored-By: Jan Michael Auer <[email protected]>
a018f0c to
fba6f5f
Compare
The source map debugger checks if a project uploaded any file with a debug ID. This check now queries `ProjectArtifactBundle` for a link of the project with `has_debug_ids = true`. It does not read the debug-ID rows of the organization anymore. The partial index from #130424 answers this query with one index lookup. This is true when the project has such a link and when it does not. A local check on a synthetic table with 2M rows gave an index-only scan on the partial index that read 4 to 6 buffers in both cases. The query is now bounded, so this PR removes the `debug-id-check-max-bundles` cap and its code path. The cap also gave a wrong result for projects whose debug IDs were only in older bundles. Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Jan Michael Auer <[email protected]> Co-authored-by: Lorenzo Cian <[email protected]>
Links created before #130422 have
has_debug_ids = false, also when their bundle has debug-ID rows. This PR adds two post-deployment migrations. Run them in this order, after #130422 is deployed to all regions:1257_backfill_projectartifactbundle_has_debug_idssets the flag on these links. It works in batches of 10,000 links ofsentry_projectartifactbundle(about 103M rows). For each batch, it reads the ID 10,000 links ahead through the primary key, then updates the ID range up to that ID, so batches stay full where IDs are sparse. For each link, it checks for one debug-ID row through theartifact_bundle_idindex. It only sets the flag totrue, so it is safe to run again. It prints a progress line every 10 batches.1258_add_projectartifactbundle_debug_ids_indexadds a partial index:Important
Large regions (
us,de): run the backfill as a custom job, not throughpost-deploy-migrations. There,1257scans about 103M rows and takes too long for the migration pipeline. The custom jobbackfill-projectartifactbundle-has-debug-ids(getsentry/getsentry#23184) runs the same queries and can resume fromSTART_FROM. The deploy fakes1257, so in these regions run only the job, then1258throughpost-deploy-migrations. Smaller regions run both migrations throughpost-deploy-migrations.The update bounds are literal values, so the planner estimates about 10,000 rows per batch and probes the debug-ID index once per link. With a bound computed in a subquery instead, it can switch to a hash join over a sequential scan of all debug-ID rows.
The table is large, so the index is a post-deployment migration, as the migration guidelines require. The migration framework creates the index concurrently, so it does not block writes. The migration is not atomic. It runs after the backfill, so that the backfill does not also write to the index.
The index contains only the links with the flag. A query for one project goes down the tree once. If the project has no such link, the query finds no entry and stops. It does not read the other links of the project.
Do not merge #130425 before the backfill and the index ran in all regions.
Requires #130422
via @jan-auer.
--
View Session [Sentry]