2020-04-28 20:09:38 -04:00
|
|
|
# Integrity check Rake task **(CORE ONLY)**
|
2016-09-29 15:08:27 -04:00
|
|
|
|
2020-04-27 02:09:51 -04:00
|
|
|
GitLab provides Rake tasks to check the integrity of various components.
|
|
|
|
|
|
|
|
## Repository integrity
|
2016-09-29 15:08:27 -04:00
|
|
|
|
|
|
|
Even though Git is very resilient and tries to prevent data integrity issues,
|
|
|
|
there are times when things go wrong. The following Rake tasks intend to
|
|
|
|
help GitLab administrators diagnose problem repositories so they can be fixed.
|
|
|
|
|
|
|
|
There are 3 things that are checked to determine integrity.
|
|
|
|
|
2019-09-26 02:06:27 -04:00
|
|
|
1. Git repository file system check ([`git fsck`](https://git-scm.com/docs/git-fsck)).
|
2016-09-29 15:08:27 -04:00
|
|
|
This step verifies the connectivity and validity of objects in the repository.
|
|
|
|
1. Check for `config.lock` in the repository directory.
|
|
|
|
1. Check for any branch/references lock files in `refs/heads`.
|
|
|
|
|
|
|
|
It's important to note that the existence of `config.lock` or reference locks
|
|
|
|
alone do not necessarily indicate a problem. Lock files are routinely created
|
|
|
|
and removed as Git and GitLab perform operations on the repository. They serve
|
|
|
|
to prevent data integrity issues. However, if a Git operation is interrupted these
|
|
|
|
locks may not be cleaned up properly.
|
|
|
|
|
|
|
|
The following symptoms may indicate a problem with repository integrity. If users
|
2020-03-31 08:08:09 -04:00
|
|
|
experience these symptoms you may use the Rake tasks described below to determine
|
2016-09-29 15:08:27 -04:00
|
|
|
exactly which repositories are causing the trouble.
|
|
|
|
|
|
|
|
- Receiving an error when trying to push code - `remote: error: cannot lock ref`
|
|
|
|
- A 500 error when viewing the GitLab dashboard or when accessing a specific project.
|
|
|
|
|
|
|
|
### Check all GitLab repositories
|
|
|
|
|
|
|
|
This task loops through all repositories on the GitLab server and runs the
|
2018-07-30 13:23:59 -04:00
|
|
|
integrity check described previously.
|
2016-09-29 15:08:27 -04:00
|
|
|
|
|
|
|
**Omnibus Installation**
|
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2018-01-04 05:02:43 -05:00
|
|
|
sudo gitlab-rake gitlab:git:fsck
|
2016-09-29 15:08:27 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
**Source Installation**
|
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2018-01-04 05:02:43 -05:00
|
|
|
sudo -u git -H bundle exec rake gitlab:git:fsck RAILS_ENV=production
|
2016-09-29 15:08:27 -04:00
|
|
|
```
|
|
|
|
|
2020-04-27 02:09:51 -04:00
|
|
|
## Uploaded files integrity
|
2018-01-08 16:22:17 -05:00
|
|
|
|
2018-06-13 13:11:43 -04:00
|
|
|
Various types of files can be uploaded to a GitLab installation by users.
|
|
|
|
These integrity checks can detect missing files. Additionally, for locally
|
|
|
|
stored files, checksums are generated and stored in the database upon upload,
|
|
|
|
and these checks will verify them against current files.
|
2018-01-08 16:22:17 -05:00
|
|
|
|
2018-02-27 14:15:25 -05:00
|
|
|
Currently, integrity checks are supported for the following types of file:
|
|
|
|
|
2018-11-13 01:07:16 -05:00
|
|
|
- CI artifacts (Available from version 10.7.0)
|
|
|
|
- LFS objects (Available from version 10.6.0)
|
|
|
|
- User uploads (Available from version 10.6.0)
|
2018-01-08 16:22:17 -05:00
|
|
|
|
|
|
|
**Omnibus Installation**
|
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2018-03-06 13:46:36 -05:00
|
|
|
sudo gitlab-rake gitlab:artifacts:check
|
2018-02-27 14:15:25 -05:00
|
|
|
sudo gitlab-rake gitlab:lfs:check
|
2018-01-08 16:22:17 -05:00
|
|
|
sudo gitlab-rake gitlab:uploads:check
|
|
|
|
```
|
|
|
|
|
|
|
|
**Source Installation**
|
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2018-03-06 13:46:36 -05:00
|
|
|
sudo -u git -H bundle exec rake gitlab:artifacts:check RAILS_ENV=production
|
2018-02-27 14:15:25 -05:00
|
|
|
sudo -u git -H bundle exec rake gitlab:lfs:check RAILS_ENV=production
|
2018-01-08 16:22:17 -05:00
|
|
|
sudo -u git -H bundle exec rake gitlab:uploads:check RAILS_ENV=production
|
|
|
|
```
|
|
|
|
|
2018-02-27 14:15:25 -05:00
|
|
|
These tasks also accept some environment variables which you can use to override
|
2018-01-09 19:02:44 -05:00
|
|
|
certain values:
|
|
|
|
|
2018-02-27 14:15:25 -05:00
|
|
|
Variable | Type | Description
|
|
|
|
--------- | ------- | -----------
|
|
|
|
`BATCH` | integer | Specifies the size of the batch. Defaults to 200.
|
|
|
|
`ID_FROM` | integer | Specifies the ID to start from, inclusive of the value.
|
|
|
|
`ID_TO` | integer | Specifies the ID value to end at, inclusive of the value.
|
|
|
|
`VERBOSE` | boolean | Causes failures to be listed individually, rather than being summarized.
|
2018-01-09 19:02:44 -05:00
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2018-03-06 13:46:36 -05:00
|
|
|
sudo gitlab-rake gitlab:artifacts:check BATCH=100 ID_FROM=50 ID_TO=250
|
2018-02-27 14:15:25 -05:00
|
|
|
sudo gitlab-rake gitlab:lfs:check BATCH=100 ID_FROM=50 ID_TO=250
|
2018-01-09 19:02:44 -05:00
|
|
|
sudo gitlab-rake gitlab:uploads:check BATCH=100 ID_FROM=50 ID_TO=250
|
|
|
|
```
|
|
|
|
|
2018-07-24 19:17:57 -04:00
|
|
|
Example output:
|
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2018-07-24 19:17:57 -04:00
|
|
|
$ sudo gitlab-rake gitlab:uploads:check
|
|
|
|
Checking integrity of Uploads
|
|
|
|
- 1..1350: Failures: 0
|
|
|
|
- 1351..2743: Failures: 0
|
|
|
|
- 2745..4349: Failures: 2
|
|
|
|
- 4357..5762: Failures: 1
|
|
|
|
- 5764..7140: Failures: 2
|
|
|
|
- 7142..8651: Failures: 0
|
|
|
|
- 8653..10134: Failures: 0
|
|
|
|
- 10135..11773: Failures: 0
|
|
|
|
- 11777..13315: Failures: 0
|
|
|
|
Done!
|
|
|
|
```
|
|
|
|
|
|
|
|
Example verbose output:
|
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2018-07-24 19:17:57 -04:00
|
|
|
$ sudo gitlab-rake gitlab:uploads:check VERBOSE=1
|
|
|
|
Checking integrity of Uploads
|
|
|
|
- 1..1350: Failures: 0
|
|
|
|
- 1351..2743: Failures: 0
|
|
|
|
- 2745..4349: Failures: 2
|
|
|
|
- Upload: 3573: #<Errno::ENOENT: No such file or directory @ rb_sysopen - /opt/gitlab/embedded/service/gitlab-rails/public/uploads/user-foo/project-bar/7a77cc52947bfe188adeff42f890bb77/image.png>
|
|
|
|
- Upload: 3580: #<Errno::ENOENT: No such file or directory @ rb_sysopen - /opt/gitlab/embedded/service/gitlab-rails/public/uploads/user-foo/project-bar/2840ba1ba3b2ecfa3478a7b161375f8a/pug.png>
|
|
|
|
- 4357..5762: Failures: 1
|
|
|
|
- Upload: 4636: #<Google::Apis::ServerError: Server error>
|
|
|
|
- 5764..7140: Failures: 2
|
|
|
|
- Upload: 5812: #<NoMethodError: undefined method `hashed_storage?' for nil:NilClass>
|
|
|
|
- Upload: 5837: #<NoMethodError: undefined method `hashed_storage?' for nil:NilClass>
|
|
|
|
- 7142..8651: Failures: 0
|
|
|
|
- 8653..10134: Failures: 0
|
|
|
|
- 10135..11773: Failures: 0
|
|
|
|
- 11777..13315: Failures: 0
|
|
|
|
Done!
|
|
|
|
```
|
|
|
|
|
2020-04-27 02:09:51 -04:00
|
|
|
## LDAP check
|
2016-09-29 15:08:27 -04:00
|
|
|
|
2020-03-23 23:09:28 -04:00
|
|
|
The LDAP check Rake task will test the bind DN and password credentials
|
2016-09-29 15:08:27 -04:00
|
|
|
(if configured) and will list a sample of LDAP users. This task is also
|
2015-12-22 16:09:35 -05:00
|
|
|
executed as part of the `gitlab:check` task, but can run independently.
|
|
|
|
See [LDAP Rake Tasks - LDAP Check](ldap.md#check) for details.
|
2020-08-18 08:10:16 -04:00
|
|
|
|
|
|
|
## Troubleshooting
|
|
|
|
|
|
|
|
The following are solutions to problems you might discover using the Rake tasks documented
|
|
|
|
above.
|
|
|
|
|
|
|
|
### Dangling commits
|
|
|
|
|
|
|
|
`gitlab:git:fsck` can find dangling commits. To fix them, try
|
|
|
|
[manually triggering housekeeping](../housekeeping.md#manual-housekeeping)
|
|
|
|
for the affected project(s).
|
|
|
|
|
|
|
|
If the issue persists, try triggering `gc` via the
|
|
|
|
[Rails Console](../troubleshooting/navigating_gitlab_via_rails_console.md#starting-a-rails-console-session):
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
p = Project.find_by_path("project-name")
|
|
|
|
Projects::HousekeepingService.new(p, :gc).execute
|
|
|
|
```
|