DropAiEventsCounts fails the 19.6 upgrade with ActiveRecord::StatementInvalid: PG::DependentObjectsStillExist error
Summary
The post-deploy migration 20261106101405_drop_ai_events_counts.rb from !268857 (merged) fails on instances that still have detached ai_events_counts partitions. The upgrade stops and gitlab-ctl reconfigure fails.
The migration shipped in 19.6.0 and 19.6.1. The 19.7 milestone on !268857 (merged) refers to the original plan, the change merged before the 19.6 cut.
Customers hit this on upgrade to 19.6.
Who hits it
Instances that upgrade through the 19.5 required stop to 19.6 while a detached ai_events_counts partition still exists:
- The partition manager detached a partition less than a week before the upgrade, so
DropDetachedPartitionsWorkerdidn't drop it yet. - Or the worker didn't run, for example on an instance that is stopped between uses.
Error
ActiveRecord::StatementInvalid: PG::DependentObjectsStillExist: ERROR: cannot drop table ai_events_counts because other objects depend on it
DETAIL: default value for column id of table gitlab_partitions_dynamic.ai_events_counts_202601 depends on sequence ai_events_counts_id_seq
...
HINT: Use DROP ... CASCADE to drop the dependent objects too.
/opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20261106101405_drop_ai_events_counts.rb:11:in `block in up'Full output: !268857 (comment 4255389995)
Cause
- The detached partitions keep
ai_events_counts_id_seqas the default forid. The parent table owns that sequence, soDROP TABLE ai_events_countsfails. - The detached partitions also keep their own copy of
fk_rails_99a3f4a8f1toorganizations.RemoveFkAiEventsCountsToOrganizationsdoesn't remove it.
Fix
- Default branch: !272133 (merged) (merged 2026-11-20). It edits the existing migration in place, with the same timestamp, so instances where the migration failed pick up the fix on the next upgrade.
- Backport to
19-6-stable-ee: !273555 (merged) (merged 2026-11-23, ships in 19.6.2). - Add a known issue for 19.6.0 and 19.6.1 to
doc/update/versions/gitlab_19_changes.md, with the workaround: !273590 (merged). Workaround also posted: #642088 (comment 4301911688)
Validation
The performance test environment that hit this passed the upgrade on the nightly build with !272133 (merged) (2026-11-23).
Edited by Jatin Parihar