Skip to content

Database: gitlab_paritions_dynamic tables blocking drop of schema

Summary

As of 551a78e7, attempting to perform rake gitlab:db:drop_tables will error out. Deploy and instance, and then perform gitlab-rake gitlab:db:drop_tables, where you will find an error out due to the relation of the tables.

Example Project

gitlab-org/charts/gitlab master pipelines

What is the current bug behavior?

gitlab-rake gitlab:db:drop_tables
rake aborted!
ActiveRecord::StatementInvalid: PG::DependentObjectsStillExist: ERROR:  cannot drop schema gitlab_partitions_dynamic because other objects depend on it
DETAIL:  table gitlab_partitions_dynamic.web_hook_logs_000000 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202107 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202108 depends on schema gitlab_partitions_dynamic
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
git@gke-production-a4b9oa-toolbox-666c6d899d-5726r:/$ /scripts/db-migrate 
Checking database migrations are up-to-date
Performing migrations (this will initialized if needed)
psql:/srv/gitlab/db/structure.sql:1: ERROR:  schema "gitlab_partitions_dynamic" already exists
rake aborted!
failed to execute:
psql --set ON_ERROR_STOP=1 --quiet --no-psqlrc --file /srv/gitlab/db/structure.sql --single-transaction gitlabhq_production

Please check the output above for any errors and make sure that `psql` is installed in your PATH and has proper permissions.

What is the expected correct behavior?

Schemas as successfully cleared, so that a restoration can proceed.

Relevant logs and/or screenshots

Possible fixes

Add CASCADE to DROP SCHEMA calls within drop_tables function of lib/tasks/gitlab/db.rake