Large organizations could not be deleted. The delete removed all check results and aggregates (purge_org_check_data) in the request's own transaction. With about 10 GB of results that runs longer than the request is allowed to, so it was cut off and rolled back.
In the request: the organization and everything with a foreign key on it are deleted as before, so the organization is gone at once. Its check data is queued in the new table org_purges.
In the background:runOrgPurges runs on every API instance, started from RunHousekeeping. It runs right after a deletion and every minute. It deletes the organization's rows one chunk at a time, each chunk in its own short transaction:
org_check_data_chunks() lists the chunks of check_results first, then those of the 1h/1d aggregates. Raw data goes first so the aggregate refresh does not re-materialize purged rows.
purge_org_check_chunk(org, chunk) deletes through the hypertable, limited to the chunk's time range, so TimescaleDB handles compressed chunks. It deletes nothing for unknown names or chunks dropped meanwhile. Both functions are SECURITY DEFINER, as purge_org_check_data was.
Leases: an instance holds an organization for 15 minutes, renewed with every chunk. If it stops, another instance takes over and repeats the chunks, which then delete nothing.
All three delete paths use this: the owner's delete, account deletion as last owner, and the admin delete.
A log line purged check data of deleted organization reports rows, chunks and duration.
Test plan
TestDeleteOrganization now also compresses the seeded chunks. It checks that the organization is gone at once with a queued purge, and that after PurgeDeletedOrgs its raw and hourly data are gone while the other organization's are kept.
TestDeleteAccount and TestModeration pass.
go test ./... passes, except TestDispatchSpreadsRandomly, which is flaky and unrelated (seen before #165, passes alone).
## Summary
Large organizations could not be deleted. The delete removed all check results and aggregates (`purge_org_check_data`) in the request's own transaction. With about 10 GB of results that runs longer than the request is allowed to, so it was cut off and rolled back.
- **In the request:** the organization and everything with a foreign key on it are deleted as before, so the organization is gone at once. Its check data is queued in the new table `org_purges`.
- **In the background:** `runOrgPurges` runs on every API instance, started from `RunHousekeeping`. It runs right after a deletion and every minute. It deletes the organization's rows one chunk at a time, each chunk in its own short transaction:
- `org_check_data_chunks()` lists the chunks of `check_results` first, then those of the `1h`/`1d` aggregates. Raw data goes first so the aggregate refresh does not re-materialize purged rows.
- `purge_org_check_chunk(org, chunk)` deletes through the hypertable, limited to the chunk's time range, so TimescaleDB handles compressed chunks. It deletes nothing for unknown names or chunks dropped meanwhile. Both functions are `SECURITY DEFINER`, as `purge_org_check_data` was.
- **Leases:** an instance holds an organization for 15 minutes, renewed with every chunk. If it stops, another instance takes over and repeats the chunks, which then delete nothing.
- All three delete paths use this: the owner's delete, account deletion as last owner, and the admin delete.
- A log line `purged check data of deleted organization` reports rows, chunks and duration.
## Test plan
- [x] `TestDeleteOrganization` now also compresses the seeded chunks. It checks that the organization is gone at once with a queued purge, and that after `PurgeDeletedOrgs` its raw and hourly data are gone while the other organization's are kept.
- [x] `TestDeleteAccount` and `TestModeration` pass.
- [x] `go test ./...` passes, except `TestDispatchSpreadsRandomly`, which is flaky and unrelated (seen before #165, passes alone).
- [x] `golangci-lint run ./...`: 0 issues.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Deleting an organization removed its check results and aggregates in the
same transaction as the request. With gigabytes of results that took
longer than the request may last, it was cut off and rolled back, so a
large organization could not be deleted at all.
The organization and everything with a foreign key on it now go in the
request; its check data is queued in org_purges. Every API instance
purges the queue a chunk at a time, each chunk in a transaction of its
own, right after a deletion and every minute. Raw results go first, so
the aggregates' refresh does not rebuild what was purged. A lease lets
another instance take over a purge whose instance stopped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi
merged commit 3f260c0712 into main2026-11-28 18:26:04 +00:00
Sebi
deleted branch feat/async-org-purge2026-11-28 18:26:07 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Large organizations could not be deleted. The delete removed all check results and aggregates (
purge_org_check_data) in the request's own transaction. With about 10 GB of results that runs longer than the request is allowed to, so it was cut off and rolled back.org_purges.runOrgPurgesruns on every API instance, started fromRunHousekeeping. It runs right after a deletion and every minute. It deletes the organization's rows one chunk at a time, each chunk in its own short transaction:org_check_data_chunks()lists the chunks ofcheck_resultsfirst, then those of the1h/1daggregates. Raw data goes first so the aggregate refresh does not re-materialize purged rows.purge_org_check_chunk(org, chunk)deletes through the hypertable, limited to the chunk's time range, so TimescaleDB handles compressed chunks. It deletes nothing for unknown names or chunks dropped meanwhile. Both functions areSECURITY DEFINER, aspurge_org_check_datawas.purged check data of deleted organizationreports rows, chunks and duration.Test plan
TestDeleteOrganizationnow also compresses the seeded chunks. It checks that the organization is gone at once with a queued purge, and that afterPurgeDeletedOrgsits raw and hourly data are gone while the other organization's are kept.TestDeleteAccountandTestModerationpass.go test ./...passes, exceptTestDispatchSpreadsRandomly, which is flaky and unrelated (seen before #165, passes alone).golangci-lint run ./...: 0 issues.🤖 Generated with Claude Code
https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3