前两天,有一位同一位同有一个需求,将Gitlab中 Project data-web (visibility: Private)修改为(visibility: internal)。修改完成后导致该项目访问的时候报错500
通过查看日志
tail -f /var/log/gitlab/gitlab-rails/production.log
发现一个关键报错
NoMethodError (undefined method `access_level' for nil:NilClass)
直接通过gitlab数据库操作解决
cat /var/opt/gitlab/gitlab-rails/etc/database.yml
切换到gitlab-psql账号并登录psql
su - gitlab-psql
psql -h /var/opt/gitlab/postgresql -d gitlabhq_production
其中project_id
是NULL
在project_features
表中。可以查找出500报错的是哪个库的project_id,得到这个project_id
SELECT id FROM projects WHERE id NOT IN (SELECT project_id AS id FROM project_features WHERE project_id is NOT NULL);
快速错误修复该报错,将查询出来的project_id,插入到project_feature表中即可修复该问题
insert into project_features(project_id,merge_requests_access_level,issues_access_level,wiki_access_level,snippets_access_level,builds_access_level,created_at,updated_at) VALUES(PROJECT_ID,10,10,10,0,10,now(),now());
参考资料
https://gitlab.com/gitlab-org/gitlab-ce/issues/37640#note_39969221
感谢其中的几位大佬!