其他分享
首页 > 其他分享> > gitlab迁移及迁移后500问题

gitlab迁移及迁移后500问题

作者:互联网

gitlab迁移

背景

环境

实施

  1. 备份
    docker exec -ti gitlab bash
    gitlab-rake gitlab:backup:create
    docker cp gitlab:/var/opt/gitlab/backups/1612427334_2021_02_04_11.11.3_gitlab_backup.tar .
  2. 在内网机器启动相同版本gitlab(gitlab备份恢复需要相同版本)
docker exec -ti gitlab bash
mv 1612427334_2021_02_04_11.11.3_gitlab_backup.tar /var/opt/gitlab/backups/
chmod 755 /var/opt/gitlab/backups/1612427334_2021_02_04_11.11.3_gitlab_backup.tar
chown root:root /var/opt/gitlab/backups/1612427334_2021_02_04_11.11.3_gitlab_backup.tar
gitlab-rake gitlab:backup:restore BACKUP=1612427334_2021_02_04_11.11.3

问题

1.进入ci/cd runner页面报500

gitlab-rails console
Ci::Runner.all.update_all(token_encrypted: nil)

gitlab-rails dbconsole
UPDATE projects SET runners_token = null, runners_token_encrypted = null; 

2.新建用户,在强制用户修改密码时报500
log 显示类似: 因为没有第一时间写文章,日志显示类似,不是我遇到的日志。


The form contains the following error:

    PG::NotNullViolation: ERROR: null value in column "id" violates not-null constraint DETAIL: Failing row contains (null, 164, t). : INSERT INTO "project_ci_cd_settings" ("project_id") VALUES (164) RETURNING "id"

解决思路:查看对应表有没有null值,启动全新的gitlab对比表结构

解决:

gitlabhq_production=> CREATE SEQUENCE user_preference_id_seq INCREMENT BY 1 NO MINVALUE NO MAXVALUE START WITH 106 OWNED BY user_preferences.id;   重新创建sequence
gitlabhq_production=> ALTER TABLE user_preferences ALTER COLUMN id SET DEFAULT NEXTVAL('user_preference_id_seq'::regclass);                         恢复表结构修饰符

3.创建merge时指定给用户时,提交后500
gitlab日志:

==> /var/log/gitlab/postgresql/current <==
2021-03-18_05:52:05.23424 ERROR:  null value in column "id" violates not-null constraint
2021-03-18_05:52:05.23427 DETAIL:  Failing row contains (null, 61, 4046).
2021-03-18_05:52:05.23427 STATEMENT:  INSERT INTO "merge_request_assignees" ("user_id", "merge_request_id") VALUES (61, 4046) RETURNING "id"

解决:

gitlabhq_production=> CREATE SEQUENCE merge_request_assignees_id_seq INCREMENT BY 1 NO MINVALUE NO MAXVALUE START WITH 106 OWNED BY merge_request_assignees.id;   重新创建sequence
gitlabhq_production=> ALTER TABLE merge_request_assignees ALTER COLUMN id SET DEFAULT NEXTVAL('merge_request_assignees_id_seq'::regclass);                         恢复表结构修饰符

说明:迁移gitlab后会有数据库序列丢失问题,重建序列,并恢复字段修饰符。对比全新gitlab你会发现,可能会丢失很多seq,建议恢复所有。

参考:https://gitlab.com/gitlab-org/gitlab/-/issues/26020

标签:gitlab,11.11,merge,迁移,null,backup,id,500
来源: https://blog.51cto.com/674564591/2674660