Gitlab migration and 500 problems after migration

Time:2021-9-26

Gitlab migration

background

  • Previously, gitlab was deployed on Alibaba cloud machines. Because the external network was relatively insecure, it was considered to move to the internal network

environment

  • Gitlab-11.11.3 docker deployment

implementation

  1. backups
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 .
  1. Start the same version of gitlab on the intranet machine (the same version is required for gitlab backup and recovery)
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

problem

1. Enter CI / CD runner page and report 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. Create a new user and press 500 when forcing the user to change the password
The log display is similar: because I didn’t write articles for the first time, the log display is similar, not the log I encountered.


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"

Solution: check whether the corresponding table has null value, and start the new gitlab comparison table structure

solve:

gitlabhq_ production=> CREATE SEQUENCE user_ preference_ id_ seq INCREMENT BY 1 NO MINVALUE NO MAXVALUE START WITH 106 OWNED BY user_ preferences.id;    Recreate sequence
gitlabhq_ production=> ALTER TABLE user_ preferences ALTER COLUMN id SET DEFAULT NEXTVAL('user_preference_id_seq'::regclass);                          Recover table structure modifier

3. When a merge is created and assigned to a user, 500 after submission
Gitlab log:

==> /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"

solve:

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;    Recreate sequence
gitlabhq_ production=> ALTER TABLE merge_ request_ assignees ALTER COLUMN id SET DEFAULT NEXTVAL('merge_request_assignees_id_seq'::regclass);                          Recover table structure modifier

Note: after migrating gitlab, the database sequence will be lost. Rebuild the sequence and recover the field modifier. Compared with the new gitlab, you will find that you may lose a lot of SEQ. It is recommended to restore all.

reference resources:https://gitlab.com/gitlab-org…

Recommended Today

Supervisor

Supervisor [note] Supervisor – H view supervisor command help Supervisorctl – H view supervisorctl command help Supervisorctl help view the action command of supervisorctl Supervisorctl help any action to view the use of this action 1. Introduction Supervisor is a process control system. Generally speaking, it can monitor your process. If the process exits abnormally, […]