I just tried switching the ownership of everything in my k8s system to postgres with “reassign owned by gitlab to postgres” and tried re-running the migrations and now it fails differently:
…
ALTER TABLE “gitlab_partitions_dynamic”.“audit_events_part_5fc467ac26_202103”
RENAME TO “audit_events_202103”;
ALTER TABLE “gitlab_partitions_dynamic”.“audit_events_part_5fc467ac26_202104”
RENAME CONSTRAINT “audit_events_part_5fc467ac26_202104_pkey” TO “audit_events_202104_pkey”;
ALTER TABLE “gitlab_partitions_dynamic”.“audit_events_part_5fc467ac26_202104”
RENAME TO “audit_events_202104”;
ALTER TABLE “gitlab_partitions_dynamic”.“audit_events_part_5fc467ac26_202105”
RENAME CONSTRAINT “audit_events_part_5fc467ac26_202105_pkey” TO “audit_events_202105_pkey”;
ALTER TABLE “gitlab_partitions_dynamic”.“audit_events_part_5fc467ac26_202105”
RENAME TO “audit_events_202105”;
ALTER TABLE “gitlab_partitions_dynamic”.“audit_events_part_5fc467ac26_202106”
RENAME CONSTRAINT “audit_events_part_5fc467ac26_202106_pkey” TO “audit_events_202106_pkey”;
ALTER TABLE “gitlab_partitions_dynamic”.“audit_events_part_5fc467ac26_202106”
RENAME TO “audit_events_202106”;
ALTER TABLE “gitlab_partitions_dynamic”.“audit_events_part_5fc467ac26_202107”
RENAME CONSTRAINT “audit_events_part_5fc467ac26_202107_pkey” TO “audit_events_202107_pkey”;
ALTER TABLE “gitlab_partitions_dynamic”.“audit_events_part_5fc467ac26_202107”
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedObject: ERROR: constraint “audit_events_part_5fc467ac26_202107_pkey” for table “audit_events_part_5fc467ac26_202107” does not exist
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in exec' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in
block (2 levels) in execute’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies/interlock.rb:48:in block in permit_concurrent_loads' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/concurrency/share_lock.rb:187:in
yield_shares’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies/interlock.rb:47:in permit_concurrent_loads' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:91:in
block in execute’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract_adapter.rb:722:in block (2 levels) in log' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in
block (2 levels) in synchronize’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in handle_interrupt' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in
block in synchronize’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in handle_interrupt' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in
synchronize’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract_adapter.rb:721:in block in log' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/notifications/instrumenter.rb:24:in
instrument’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract_adapter.rb:712:in log' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:90:in
execute’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/marginalia-1.10.0/lib/marginalia.rb:71:in execute_with_marginalia' /srv/gitlab/lib/gitlab/database/partitioning/replace_table.rb:32:in
execute’
/srv/gitlab/lib/gitlab/database/partitioning/replace_table.rb:27:in perform' /srv/gitlab/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers.rb:425:in
block in replace_table’
/srv/gitlab/lib/gitlab/database/with_lock_retries.rb:121:in run_block' /srv/gitlab/lib/gitlab/database/with_lock_retries.rb:130:in
block in run_block_with_transaction’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in block in transaction' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/transaction.rb:280:in
block in within_new_transaction’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in block (2 levels) in synchronize' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in
handle_interrupt’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in block in synchronize' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in
handle_interrupt’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in synchronize' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/transaction.rb:278:in
within_new_transaction’
/srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in transaction' /srv/gitlab/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/transactions.rb:212:in
transaction’
/srv/gitlab/lib/gitlab/database/with_lock_retries.rb:125:in run_block_with_transaction' /srv/gitlab/lib/gitlab/database/with_lock_retries.rb:95:in
run’
/srv/gitlab/lib/gitlab/database/migration_helpers.rb:394:in with_lock_retries' /srv/gitlab/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers.rb:422:in
replace_table’
/srv/gitlab/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers.rb:206:in replace_with_partitioned_table' /srv/gitlab/db/migrate/20201112215132_swap_partitioned_audit_events.rb:9:in
up’