Backport of 'Drop detached ai_events_counts partitions before the table'

What does this MR do and why?

Backports !272133 (merged) to 19.6.

Related to #642088 (S1, customers blocked on the upgrade to 19.6).

DropAiEventsCounts shipped in 19.6.0. It fails with PG::DependentObjectsStillExist on an instance that still has ai_events_counts partitions that the partition manager detached but DropDetachedPartitionsWorker has not dropped yet, because those tables still use ai_events_counts_id_seq. Detached partitions are kept for a week, so an instance that upgrades through the 19.5 stop to 19.6 within a week of a detach, or where the worker did not run, hits this. The fix drops those detached tables first, after their foreign keys, and removes their detached_partitions rows.

Reported in !268857 (comment 4263464533). The backport was requested in the database review of !272133 (merged).

  • Cherry-pick of 941a2d70 (the squash commit of !272133 (merged)), with -x.
  • The migrations, the spec and db/docs/deleted_tables/ai_events_counts.yml are identical to the default branch.
  • The only conflict was .rubocop_todo/rspec/spec_file_path_format.yml: the stable branch's list differs from the default branch, so this MR keeps the stable branch's file and adds only the new spec path.

Data deletion

  • Records affected: only ai_events_counts_* partitions that the partition manager already detached and DropDetachedPartitionsWorker hasn't dropped yet, plus their detached_partitions rows. The worker would delete them within a week anyway. On GitLab.com, none: the migration already ran and nothing was left. The rest of the table is dropped by !268857 (merged), see its data deletion section.
  • User impact: none. Nothing reads ai_events_counts since 19.5.
  • Recovery: not needed, this data was already scheduled for deletion. Rolling back recreates the empty table, as before.

Same as !272133 (merged).

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

  • This MR is backporting a bug fix, documentation update, or spec fix, previously merged in the default branch.
  • The MR that fixed the bug on the default branch has been deployed to GitLab.com (not applicable for documentation or spec changes).
  • The MR title is descriptive (e.g. "Backport of 'title of default branch MR'"). This is important, since the title will be copied to the patch blog post.
  • Required labels have been applied to this merge request
  • This MR has been approved by a maintainer (only one approval is required).
  • Ensure the E2E Omnibus GitLab EE pipeline (triggered by thee2e:test-on-omnibus-ee job) has succeeded. If it has failed (or shows warnings), investigate the failures. If you determine the failures are unrelated, you may proceed. If you need assistance investigating, request help in the #s_developer_experience Slack channel to confirm the failures are unrelated to the merge request.

Note to the merge request author and maintainer

If you have questions about the patch release process, please:

Edited by Manoj M J

Merge request reports

Loading
Loading