↑日記で日々積み重ねた情報をトップの「わんこのページ」にまとめています。

おのたく日記 [RDF] YouTubeも始めました→


2023-11-18(Sat) [長年日記]

GitLab 16.6.0へのアップグレードでデータベースマイグレーションに失敗する

毎回のことですが、今月も新しいGitLabのバージョンがリリースされたのでアップグレードしました。しかし、またしてもエラーによりアップグレードができませんでした。

以下のエラーメッセージが表示されました。

gitlab-ce-gitlab-ce-1 | PG::UndefinedObject: ERROR: constraint "fk_262d4c2d19" for table "ci_pipelines" does not exist

gitlab-ce-gitlab-ce-1 | /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migrations/constraints_helpers.rb:253:in `rename_constraint`

同様のエラーが以前にも発生していないか調べてみました。以下の情報を見つけました:

gitlabhq_development=# \d+ ci_pipelines

...

Referenced by:

TABLE "ci_pipelines" CONSTRAINT "fk_262d4c2d19" FOREIGN KEY (auto_canceled_by_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL

TABLE "ci_pipeline_chat_data" CONSTRAINT "fk_5b21bde562" FOREIGN KEY (pipeline_id_convert_to_bigint) REFERENCES ci_pipelines(id) ON DELETE CASCADE

TABLE "p_ci_builds" CONSTRAINT "fk_87f4cefcda" FOREIGN KEY (upstream_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE

TABLE "p_ci_builds" CONSTRAINT "fk_a2141b1522" FOREIGN KEY (auto_canceled_by_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL

TABLE "p_ci_builds" CONSTRAINT "fk_d3130c9a7f" FOREIGN KEY (commit_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE

[Ensure that all tables that reference ci_pipelines have partition_id columnより引用]

上記の情報から、ci_pipelinesを参照しているテーブルにfk_262d4c2d19という制約が存在しないことがわかりました。

次に、以下の手順で修正を試みました:

上記の手順で修正を行ったところ、次のエラーが発生しました:

gitlab-ce-gitlab-ce-1 | Caused by:

gitlab-ce-gitlab-ce-1 | PG::UndefinedObject: ERROR: constraint "fk_fb57e6cc56" for table "ci_stages" does not exist

gitlab-ce-gitlab-ce-1 | /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migrations/constraints_helpers.rb:253:in `rename_constraint

ので、同様に

Foreign-key constraints:

"fk_c5ddde695f" FOREIGN KEY (pipeline_id_convert_to_bigint) REFERENCES ci_pipelines(id) ON DELETE CASCADE

"fk_fb57e6cc56" FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE

[Prepare foreign key constraints for bigint ci_stages.pipeline_idより引用]

上記の情報から、ci_pipelinesを参照しているテーブルにfk_262d4c2d19という制約が存在しないことがわかりました。

次に、以下の手順で修正を試みました:

$ docker compose exec gitlab-ce bash

root@gitlab-ce:/# gitlab-ctl status

run: gitaly: (pid 307) 30s; run: log: (pid 305) 30s

run: gitlab-kas: (pid 373) 19s; run: log: (pid 372) 19s

run: gitlab-sshd: (pid 311) 30s; run: log: (pid 310) 30s

run: logrotate: (pid 309) 30s; run: log: (pid 306) 30s

run: postgresql: (pid 375) 19s; run: log: (pid 374) 19s

run: redis: (pid 312) 30s; run: log: (pid 308) 30s

run: sshd: (pid 38) 80s; run: log: (pid 37) 80s

root@gitlab-ce:/# gitlab-psql

psql (13.11)

Type "help" for help.

gitlabhq_production=# ALTER TABLE ci_stages ADD CONSTRAINT fk_fb57e6cc56 FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE;

ALTER TABLE

gitlabhq_production=# \q

root@gitlab-ce:/# exit

としらたら、無事にマイグレーションが終わって無事に16.6.0が起動しました。

GitLabのissueに入れるべきだけど、午前4時で眠いのでまた

本日のPingbacks(全0件)

Google Web検索 on-o.com内を検索