chore: expand gerrit delete activities script#4080
Conversation
…es as filters Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
2 similar comments
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4b50a8f. Configure here.
| const fetchQuery = `SELECT "activityId" FROM "activityRelations" WHERE ${where} LIMIT ${batchSize}` | ||
|
|
There was a problem hiding this comment.
@joanagmaia did you test how this performs?
The main reason behind using tb to get activity IDs was performance
…ect PG delete (CM-1298) Ports safety improvements proposed in #4080 onto the parameterized script: - Split into separate Tinybird (unquoted) and Postgres (pg-promise params, "updatedAt" double-quoted) filter builders so each store gets its own dialect. - Add cheap pre-flight Tinybird count() on both datasources to show blast radius before any destructive action. - Interactive confirmation prompt with --yes / -y bypass for non-interactive runs. - Switch PG cleanup to direct chunked DELETE (fetch matching IDs from PG, delete by PK) rather than streaming IDs from Tinybird. Decouples PG cleanup throughput from Tinybird. - Extend Tinybird job wait timeout from 1h to 6h for large bulk deletes. - Persist result JSON immediately after triggering TB jobs so the job IDs survive a wait timeout. - Docstring note that derived MVs are not cascaded by raw datasource deletes. Supersedes #4080. Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>

Summary
--typeand--before-dateCLI flags, making the scriptreusable for different cleanup scenarios without code changes.
activityRelations) in parallel before any deletion, so the operator can see the blast radius upfront.
--yes/-y) to prevent accidental mass deletions.WHERE ... LIMIT 10k loop, removing the dependency on Tinybird to drive the Postgres cleanup.
--before-date(YYYY-MM-DD format check) and--type(enum guard againstVALID_GERRIT_TYPES), with an explicit warning when neither filter is provided (would delete all Gerrit
activities).
Note
Medium Risk
Medium risk because it changes a destructive cleanup script’s deletion targeting and execution flow across Postgres and Tinybird; incorrect flags or filter construction could delete unintended data.
Overview
Expands the Gerrit activities cleanup tooling by adding a
cleanup-gerrit-activitiesscript entry and refactoring the cleanup script to accept--typeand--before-datefilters (with validation), plus--yes/-yto skip an interactive confirmation.The script now performs pre-flight Tinybird row counts, warns when no filters are provided, deletes matching Postgres
activityRelationsvia chunked 10k batches (no longer driven by Tinybird ID pagination), triggers one Tinybird delete job per datasource, and persists job IDs/status to a/tmpresult file before optionally waiting for completion.Reviewed by Cursor Bugbot for commit 70aca0e. Bugbot is set up for automated code reviews on this repo. Configure here.