You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitLab升级后报502错误及内存映射文件分配失败问题排查求助

升级GitLab EE后出现502错误及ENOSPC问题排查

环境信息

运行系统:Debian 11.8
GitLab版本:

# dpkg -l | grep gitlab
ii  gitlab-ee                      16.7.0-ee.0                    amd64        GitLab Enterprise Edition (including NGINX, Postgres, Redis)
ii  gitlab-runner                  16.7.0                         amd64        GitLab Runner

问题现象

  • 升级gitlab-ee后服务无法正常运行,网站返回502错误
  • 日志中大量出现IOError,提示ENOSPC: No space left on device,无法在/run/gitlab/puma/目录下创建内存映射文件,示例日志片段:
{"severity":"ERROR","time":"2023-12-23T23:39:53.299Z","exception.class":"IOError","exception.message":"Can't reserve 4096 bytes for memory-mapped file in /run/gitlab/puma/gauge_all_puma_6-0.db: ENOSPC: No space left on device","exception.backtrace":["config/initializers/7_prometheus_metrics.rb:82:in `block in \u003ctop (required)\u003e'","lib/gitlab/cluster/lifecycle_events.rb:173:in `block in call'","lib/gitlab/cluster/lifecycle_events.rb:172:in `each'","lib/gitlab/cluster/lifecycle_events.rb:172:in `call'","lib/gitlab/cluster/lifecycle_events.rb:133:in `do_worker_start'"],"user.username":null,"tags.program":"web","tags.locale":"en","tags.feature_category":null,"tags.correlation_id":null}
  • 执行df -h显示/run目录空间充足:
# df -h 
Filesystem      Size  Used Avail Use% Mounted on
udev             32G     0   32G   0% /dev
tmpfs           6.3G  6.5M  6.3G   1% /run
/dev/md2        906G  609G  252G  71% /
tmpfs            32G   52K   32G   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/md1        485M  105M  355M  23% /boot
tmpfs           6.3G     0  6.3G   0% /run/user/1000

已尝试操作

  • 重启GitLab服务
  • 重启系统
  • 清理旧Docker文件
  • 在gitlab.rb中设置prometheus_monitoring['enable'] = false,执行gitlab-ctl reconfigure后重启服务,问题仍存在

进一步排查步骤

1. 检查/run目录inode使用情况

ENOSPC错误可能是inode耗尽而非磁盘空间不足,执行以下命令确认:

df -i /run

如果inode使用率接近100%,需清理/run下的临时文件释放inode。

2. 检查tmpfs挂载参数

/run是tmpfs文件系统,默认有inode数量限制,查看挂载参数:

mount | grep /run

若inode数不足,可修改/etc/fstab中tmpfs的挂载选项,增加nr_inodes参数(例如nr_inodes=1000000):

tmpfs /run tmpfs defaults,noatime,nr_inodes=1000000 0 0

修改后重新挂载:

mount -o remount /run

3. 禁用Puma自身metrics

即使关闭了Prometheus,Puma的metrics可能仍在运行,在gitlab.rb中添加:

puma['metrics_enabled'] = false

执行配置更新和服务重启:

gitlab-ctl reconfigure
gitlab-ctl restart puma

4. 清理/run/gitlab下的Puma临时文件

停止GitLab服务后,删除Puma的临时文件再重启:

gitlab-ctl stop
rm -rf /run/gitlab/puma/*
gitlab-ctl start

5. 检查安全模块限制

若系统启用了SELinux或AppArmor,可能阻止GitLab在/run下创建文件:

  • 检查SELinux状态:sestatus,临时关闭测试:setenforce 0
  • 检查AppArmor状态:aa-status,查看GitLab相关profile的规则是否存在拒绝操作

6. 查看Puma详细启动日志

获取Puma启动时的完整错误信息:

gitlab-ctl tail puma

内容的提问来源于stack exchange,提问作者Janning Vygen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 15:21:06