2020-06-03 17:08:23 -04:00
---
stage: Enablement
group: Geo
2020-11-26 01:09:20 -05:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-06-03 17:08:23 -04:00
type: howto
---
2021-01-28 07:09:54 -05:00
# Troubleshooting Geo **(PREMIUM SELF)**
2019-05-05 12:08:21 -04:00
Setting up Geo requires careful attention to details and sometimes it's easy to
2019-06-21 06:33:37 -04:00
miss a step.
Here is a list of steps you should take to attempt to fix problem:
- Perform [basic troubleshooting ](#basic-troubleshooting ).
- Fix any [replication errors ](#fixing-replication-errors ).
- Fix any [common ](#fixing-common-errors ) errors.
2019-05-05 12:08:21 -04:00
2019-06-21 06:33:37 -04:00
## Basic troubleshooting
Before attempting more advanced troubleshooting:
- Check [the health of the **secondary** node ](#check-the-health-of-the-secondary-node ).
- Check [if PostgreSQL replication is working ](#check-if-postgresql-replication-is-working ).
### Check the health of the **secondary** node
2019-05-05 12:08:21 -04:00
2020-07-29 20:09:53 -04:00
Visit the **primary** node's **Admin Area > Geo** (`/admin/geo/nodes`) in
2019-05-05 12:08:21 -04:00
your browser. We perform the following health checks on each **secondary** node
to help identify if something is wrong:
- Is the node running?
- Is the node's secondary database configured for streaming replication?
- Is the node's secondary tracking database configured?
- Is the node's secondary tracking database connected?
- Is the node's secondary tracking database up-to-date?
2020-12-04 07:09:39 -05:00
![Geo health check ](img/geo_node_dashboard.png )
2019-05-05 12:08:21 -04:00
2019-06-21 06:33:37 -04:00
For information on how to resolve common errors reported from the UI, see
[Fixing Common Errors ](#fixing-common-errors ).
2019-05-26 20:37:41 -04:00
2019-05-05 12:08:21 -04:00
If the UI is not working, or you are unable to log in, you can run the Geo
health check manually to get this information as well as a few more details.
2019-06-21 06:33:37 -04:00
2020-07-28 11:09:36 -04:00
#### Health check Rake task
2020-03-31 08:08:09 -04:00
This Rake task can be run on an app node in the **primary** or **secondary**
2019-05-05 12:08:21 -04:00
Geo nodes:
2020-01-30 10:09:15 -05:00
```shell
2019-05-05 12:08:21 -04:00
sudo gitlab-rake gitlab:geo:check
```
Example output:
2020-03-05 22:08:08 -05:00
```plaintext
2019-05-05 12:08:21 -04:00
Checking Geo ...
GitLab Geo is available ... yes
GitLab Geo is enabled ... yes
2020-01-09 01:07:57 -05:00
This machine's Geo node name matches a database record ... yes, found a secondary node named "Shanghai"
2019-05-05 12:08:21 -04:00
GitLab Geo secondary database is correctly configured ... yes
2019-05-26 20:37:41 -04:00
Database replication enabled? ... yes
Database replication working? ... yes
2019-05-05 12:08:21 -04:00
GitLab Geo HTTP(S) connectivity ...
* Can connect to the primary node ... yes
HTTP/HTTPS repository cloning is enabled ... yes
Machine clock is synchronized ... yes
Git user has default SSH configuration? ... yes
OpenSSH configured to use AuthorizedKeysCommand ... yes
GitLab configured to disable writing to authorized_keys file ... yes
GitLab configured to store new projects in hashed storage? ... yes
All projects are in hashed storage? ... yes
Checking Geo ... Finished
```
2020-07-28 11:09:36 -04:00
#### Sync status Rake task
2020-03-31 08:08:09 -04:00
Current sync information can be found manually by running this Rake task on any
2019-05-05 12:08:21 -04:00
**secondary** app node:
2020-01-30 10:09:15 -05:00
```shell
2019-05-05 12:08:21 -04:00
sudo gitlab-rake geo:status
```
Example output:
2020-03-05 22:08:08 -05:00
```plaintext
2019-05-05 12:08:21 -04:00
http://secondary.example.com/
-----------------------------------------------------
2019-05-26 20:37:41 -04:00
GitLab Version: 11.10.4-ee
2019-05-05 12:08:21 -04:00
Geo Role: Secondary
Health Status: Healthy
2019-05-26 20:37:41 -04:00
Repositories: 289/289 (100%)
Verified Repositories: 289/289 (100%)
Wikis: 289/289 (100%)
Verified Wikis: 289/289 (100%)
LFS Objects: 8/8 (100%)
Attachments: 5/5 (100%)
CI job artifacts: 0/0 (0%)
Repositories Checked: 0/289 (0%)
2019-05-05 12:08:21 -04:00
Sync Settings: Full
Database replication lag: 0 seconds
2019-05-26 20:37:41 -04:00
Last event ID seen from primary: 10215 (about 2 minutes ago)
Last event ID processed by cursor: 10215 (about 2 minutes ago)
Last status report was: 2 minutes ago
2019-05-05 12:08:21 -04:00
```
2019-06-21 06:33:37 -04:00
### Check if PostgreSQL replication is working
To check if PostgreSQL replication is working, check if:
- [Nodes are pointing to the correct database instance ](#are-nodes-pointing-to-the-correct-database-instance ).
- [Geo can detect the current node correctly ](#can-geo-detect-the-current-node-correctly ).
2019-05-05 12:08:21 -04:00
2019-06-21 06:33:37 -04:00
#### Are nodes pointing to the correct database instance?
2019-05-05 12:08:21 -04:00
You should make sure your **primary** Geo node points to the instance with
writing permissions.
Any **secondary** nodes should point only to read-only instances.
2019-06-21 06:33:37 -04:00
#### Can Geo detect the current node correctly?
2019-05-05 12:08:21 -04:00
2020-01-09 01:07:57 -05:00
Geo finds the current machine's Geo node name in `/etc/gitlab/gitlab.rb` by:
2019-11-27 04:06:29 -05:00
- Using the `gitlab_rails['geo_node_name']` setting.
- If that is not defined, using the `external_url` setting.
2020-07-29 20:09:53 -04:00
This name is used to look up the node with the same **Name** in **Admin Area > Geo** .
2019-10-24 02:07:07 -04:00
2020-01-09 01:07:57 -05:00
To check if the current machine has a node name that matches a node in the
database, run the check task:
2019-05-05 12:08:21 -04:00
2020-01-30 10:09:15 -05:00
```shell
2020-01-09 01:07:57 -05:00
sudo gitlab-rake gitlab:geo:check
2019-05-05 12:08:21 -04:00
```
2020-01-09 01:07:57 -05:00
It displays the current machine's node name and whether the matching database
record is a **primary** or **secondary** node.
2019-05-05 12:08:21 -04:00
2020-03-05 22:08:08 -05:00
```plaintext
2020-01-09 01:07:57 -05:00
This machine's Geo node name matches a database record ... yes, found a secondary node named "Shanghai"
2019-05-05 12:08:21 -04:00
```
2020-03-05 22:08:08 -05:00
```plaintext
2020-01-09 01:07:57 -05:00
This machine's Geo node name matches a database record ... no
Try fixing it:
You could add or update a Geo node database record, setting the name to "https://example.com/".
Or you could set this machine's Geo node name to match the name of an existing database record: "London", "Shanghai"
For more information see:
doc/administration/geo/replication/troubleshooting.md#can-geo-detect-the-current-node-correctly
```
2019-05-05 12:08:21 -04:00
2020-03-31 08:08:09 -04:00
## Fixing errors found when running the Geo check Rake task
2019-11-11 13:06:27 -05:00
2020-03-31 08:08:09 -04:00
When running this Rake task, you may see errors if the nodes are not properly configured:
2019-11-11 13:06:27 -05:00
2020-01-30 10:09:15 -05:00
```shell
2019-11-11 13:06:27 -05:00
sudo gitlab-rake gitlab:geo:check
```
1. Rails did not provide a password when connecting to the database
2020-03-05 22:08:08 -05:00
```plaintext
Checking Geo ...
2019-11-11 13:06:27 -05:00
2020-03-05 22:08:08 -05:00
GitLab Geo is available ... Exception: fe_sendauth: no password supplied
GitLab Geo is enabled ... Exception: fe_sendauth: no password supplied
...
Checking Geo ... Finished
```
2019-11-11 13:06:27 -05:00
2020-03-05 22:08:08 -05:00
- Ensure that you have the `gitlab_rails['db_password']` set to the plain text-password used when creating the hash for `postgresql['sql_user_password']` .
2019-11-11 13:06:27 -05:00
1. Rails is unable to connect to the database
2020-03-05 22:08:08 -05:00
```plaintext
Checking Geo ...
2019-11-11 13:06:27 -05:00
2020-03-05 22:08:08 -05:00
GitLab Geo is available ... Exception: FATAL: no pg_hba.conf entry for host "1.1.1.1", user "gitlab", database "gitlabhq_production", SSL on
FATAL: no pg_hba.conf entry for host "1.1.1.1", user "gitlab", database "gitlabhq_production", SSL off
GitLab Geo is enabled ... Exception: FATAL: no pg_hba.conf entry for host "1.1.1.1", user "gitlab", database "gitlabhq_production", SSL on
FATAL: no pg_hba.conf entry for host "1.1.1.1", user "gitlab", database "gitlabhq_production", SSL off
...
Checking Geo ... Finished
```
2019-11-11 13:06:27 -05:00
2020-03-05 22:08:08 -05:00
- Ensure that you have the IP address of the rails node included in `postgresql['md5_auth_cidr_addresses']` .
- Ensure that you have included the subnet mask on the IP address: `postgresql['md5_auth_cidr_addresses'] = ['1.1.1.1/32']` .
2019-11-11 13:06:27 -05:00
1. Rails has supplied the incorrect password
2020-03-05 22:08:08 -05:00
```plaintext
Checking Geo ...
GitLab Geo is available ... Exception: FATAL: password authentication failed for user "gitlab"
FATAL: password authentication failed for user "gitlab"
GitLab Geo is enabled ... Exception: FATAL: password authentication failed for user "gitlab"
FATAL: password authentication failed for user "gitlab"
...
Checking Geo ... Finished
```
2019-11-11 13:06:27 -05:00
2020-03-05 22:08:08 -05:00
- Verify the correct password is set for `gitlab_rails['db_password']` that was used when creating the hash in `postgresql['sql_user_password']` by running `gitlab-ctl pg-password-md5 gitlab` and entering the password.
2019-11-11 13:06:27 -05:00
2020-07-28 11:09:36 -04:00
1. Check returns `not a secondary node`
2019-11-11 13:06:27 -05:00
2020-03-05 22:08:08 -05:00
```plaintext
Checking Geo ...
2019-11-11 13:06:27 -05:00
2020-03-05 22:08:08 -05:00
GitLab Geo is available ... yes
GitLab Geo is enabled ... yes
GitLab Geo secondary database is correctly configured ... not a secondary node
Database replication enabled? ... not a secondary node
...
Checking Geo ... Finished
```
2019-11-11 13:06:27 -05:00
2020-03-05 22:08:08 -05:00
- Ensure that you have added the secondary node in the Admin Area of the **primary** node.
2021-02-15 19:09:01 -05:00
- Ensure that you entered the `external_url` or `gitlab_rails['geo_node_name']` when adding the secondary node in the Admin Area of the **primary** node.
2020-03-05 22:08:08 -05:00
- Prior to GitLab 12.4, edit the secondary node in the Admin Area of the **primary** node and ensure that there is a trailing `/` in the `Name` field.
2019-11-11 13:06:27 -05:00
2020-03-13 05:09:23 -04:00
1. Check returns `Exception: PG::UndefinedTable: ERROR: relation "geo_nodes" does not exist`
2019-11-11 13:06:27 -05:00
2020-03-05 22:08:08 -05:00
```plaintext
Checking Geo ...
GitLab Geo is available ... no
Try fixing it:
Upload a new license that includes the GitLab Geo feature
For more information see:
https://about.gitlab.com/features/gitlab-geo/
GitLab Geo is enabled ... Exception: PG::UndefinedTable: ERROR: relation "geo_nodes" does not exist
LINE 8: WHERE a.attrelid = '"geo_nodes"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
c.collname, col_description(a.attrelid, a.attnum) AS comment
FROM pg_attribute a
LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
LEFT JOIN pg_type t ON a.atttypid = t.oid
LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation < > t.typcollation
WHERE a.attrelid = '"geo_nodes"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
...
Checking Geo ... Finished
```
2020-03-23 23:09:28 -04:00
When performing a PostgreSQL major version (9 > 10) update this is expected. Follow:
2020-03-05 22:08:08 -05:00
2020-09-17 11:09:24 -04:00
- [initiate-the-replication-process ](../setup/database.md#step-3-initiate-the-replication-process )
2019-11-11 13:06:27 -05:00
2019-06-21 06:33:37 -04:00
## Fixing replication errors
The following sections outline troubleshooting steps for fixing replication
2020-07-28 11:09:36 -04:00
errors (indicated by `Database replication working? ... no` in the
[`geo:check` output ](#health-check-rake-task ).
2019-06-21 06:33:37 -04:00
2020-03-13 05:09:23 -04:00
### Message: `ERROR: replication slots can only be used if max_replication_slots > 0`?
2019-05-05 12:08:21 -04:00
This means that the `max_replication_slots` PostgreSQL variable needs to
be set on the **primary** database. In GitLab 9.4, we have made this setting
default to 1. You may need to increase this value if you have more
2019-06-21 06:33:37 -04:00
**secondary** nodes.
Be sure to restart PostgreSQL for this to take
2019-05-05 12:08:21 -04:00
effect. See the [PostgreSQL replication
2020-09-17 11:09:24 -04:00
setup](../setup/database.md#postgresql-replication) guide for more details.
2019-05-05 12:08:21 -04:00
2020-03-13 05:09:23 -04:00
### Message: `FATAL: could not start WAL streaming: ERROR: replication slot "geo_secondary_my_domain_com" does not exist`?
2019-05-05 12:08:21 -04:00
This occurs when PostgreSQL does not have a replication slot for the
2019-06-21 06:33:37 -04:00
**secondary** node by that name.
You may want to rerun the [replication
2020-09-17 11:09:24 -04:00
process](../setup/database.md) on the **secondary** node .
2019-05-05 12:08:21 -04:00
2019-06-21 06:33:37 -04:00
### Message: "Command exceeded allowed execution time" when setting up replication?
2019-05-05 12:08:21 -04:00
2020-09-17 11:09:24 -04:00
This may happen while [initiating the replication process ](../setup/database.md#step-3-initiate-the-replication-process ) on the **secondary** node,
2019-05-05 12:08:21 -04:00
and indicates that your initial dataset is too large to be replicated in the default timeout (30 minutes).
Re-run `gitlab-ctl replicate-geo-database` , but include a larger value for
`--backup-timeout` :
2020-01-30 10:09:15 -05:00
```shell
2019-05-05 12:08:21 -04:00
sudo gitlab-ctl \
replicate-geo-database \
--host=< primary_node_hostname > \
--slot-name=< secondary_slot_name > \
--backup-timeout=21600
```
This will give the initial replication up to six hours to complete, rather than
the default thirty minutes. Adjust as required for your installation.
2020-03-08 20:08:14 -04:00
### Message: "PANIC: could not write to file `pg_xlog/xlogtemp.123`: No space left on device"
2019-05-05 12:08:21 -04:00
Determine if you have any unused replication slots in the **primary** database. This can cause large amounts of
log data to build up in `pg_xlog` . Removing the unused slots can reduce the amount of space used in the `pg_xlog` .
1. Start a PostgreSQL console session:
2020-01-30 10:09:15 -05:00
```shell
2020-01-14 16:07:45 -05:00
sudo gitlab-psql
2019-07-02 21:37:27 -04:00
```
2019-05-05 12:08:21 -04:00
2020-12-15 22:09:46 -05:00
NOTE:
Using `gitlab-rails dbconsole` will not work, because managing replication slots requires superuser permissions.
2019-05-05 12:08:21 -04:00
1. View your replication slots with:
2019-07-02 21:37:27 -04:00
```sql
SELECT * FROM pg_replication_slots;
```
2019-05-05 12:08:21 -04:00
Slots where `active` is `f` are not active.
- When this slot should be active, because you have a **secondary** node configured using that slot,
log in to that **secondary** node and check the PostgreSQL logs why the replication is not running.
- If you are no longer using the slot (e.g. you no longer have Geo enabled), you can remove it with in the
PostgreSQL console session:
2019-07-02 21:37:27 -04:00
```sql
SELECT pg_drop_replication_slot('< name_of_extra_slot > ');
```
2019-05-05 12:08:21 -04:00
2020-01-07 19:07:43 -05:00
### Message: "ERROR: canceling statement due to conflict with recovery"
This error may rarely occur under normal usage, and the system is resilient
enough to recover.
However, under certain conditions, some database queries on secondaries may run
excessively long, which increases the frequency of this error. At some point,
some of these queries will never be able to complete due to being canceled
every time.
These long-running queries are
2020-05-21 02:08:25 -04:00
[planned to be removed in the future ](https://gitlab.com/gitlab-org/gitlab/-/issues/34269 ),
2020-01-07 19:07:43 -05:00
but as a workaround, we recommend enabling
[hot_standby_feedback ](https://www.postgresql.org/docs/10/hot-standby.html#HOT-STANDBY-CONFLICT ).
This increases the likelihood of bloat on the **primary** node as it prevents
`VACUUM` from removing recently-dead rows. However, it has been used
successfully in production on GitLab.com.
To enable `hot_standby_feedback` , add the following to `/etc/gitlab/gitlab.rb`
on the **secondary** node:
```ruby
postgresql['hot_standby_feedback'] = 'on'
```
Then reconfigure GitLab:
2020-01-30 10:09:15 -05:00
```shell
2020-01-07 19:07:43 -05:00
sudo gitlab-ctl reconfigure
```
To help us resolve this problem, consider commenting on
2020-05-21 02:08:25 -04:00
[the issue ](https://gitlab.com/gitlab-org/gitlab/-/issues/4489 ).
2020-01-07 19:07:43 -05:00
2020-03-30 23:07:51 -04:00
### Message: `LOG: invalid CIDR mask in address`
This happens on wrongly-formatted addresses in `postgresql['md5_auth_cidr_addresses']` .
```plaintext
2020-03-20_23:59:57.60499 LOG: invalid CIDR mask in address "***"
2020-03-20_23:59:57.60501 CONTEXT: line 74 of configuration file "/var/opt/gitlab/postgresql/data/pg_hba.conf"
```
To fix this, update the IP addresses in `/etc/gitlab/gitlab.rb` under `postgresql['md5_auth_cidr_addresses']`
to respect the CIDR format (i.e. `1.2.3.4/32` ).
### Message: `LOG: invalid IP mask "md5": Name or service not known`
This happens when you have added IP addresses without a subnet mask in `postgresql['md5_auth_cidr_addresses']` .
```plaintext
2020-03-21_00:23:01.97353 LOG: invalid IP mask "md5": Name or service not known
2020-03-21_00:23:01.97354 CONTEXT: line 75 of configuration file "/var/opt/gitlab/postgresql/data/pg_hba.conf"
```
To fix this, add the subnet mask in `/etc/gitlab/gitlab.rb` under `postgresql['md5_auth_cidr_addresses']`
to respect the CIDR format (i.e. `1.2.3.4/32` ).
2020-09-21 14:09:58 -04:00
### Message: `Found data in the gitlabhq_production database!` when running `gitlab-ctl replicate-geo-database`
This happens if data is detected in the `projects` table. When one or more projects are detected, the operation
is aborted to prevent accidental data loss. To bypass this message, pass the `--force` option to the command.
In GitLab 13.4, a seed project is added when GitLab is first installed. This makes it necessary to pass `--force` even
on a new Geo secondary node. There is an [issue to account for seed projects ](https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/5618 )
when checking the database.
2021-02-12 13:08:59 -05:00
### Message: `Synchronization failed - Error syncing repository`
WARNING:
If large repositories are affected by this problem,
their resync may take a long time and cause significant load on your Geo nodes,
storage and network systems.
If you get the error `Synchronization failed - Error syncing repository` along with the following log messages, this indicates that the expected `geo` remote is not present in the `.git/config` file
of a repository on the secondary Geo node's filesystem:
```json
{
"created": "@1603481145.084348757",
"description": "Error received from peer unix:/var/opt/gitlab/gitaly/gitaly.socket",
…
"grpc_message": "exit status 128",
"grpc_status": 13
}
{ …
"grpc.request.fullMethod": "/gitaly.RemoteService/FindRemoteRootRef",
"grpc.request.glProjectPath": "< namespace > /< project > ",
…
"level": "error",
"msg": "fatal: 'geo' does not appear to be a git repository
fatal: Could not read from remote repository. …",
}
```
To solve this:
1. Log into the secondary Geo node.
2021-02-23 01:11:16 -05:00
1. Back up [the `.git` folder ](../../repository_storage_types.md#translate-hashed-storage-paths ).
2021-02-12 13:08:59 -05:00
1. Optional: [Spot-check ](../../troubleshooting/log_parsing.md#find-all-projects-affected-by-a-fatal-git-problem ))
a few of those IDs whether they indeed correspond
to a project with known Geo replication failures.
Use `fatal: 'geo'` as the `grep` term and the following API call:
```shell
curl --request GET --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/< first_failed_geo_sync_ID > "
```
1. Enter the [Rails console ](../../troubleshooting/navigating_gitlab_via_rails_console.md ) and run:
```ruby
failed_geo_syncs = Geo::ProjectRegistry.failed.pluck(:id)
failed_geo_syncs.each do |fgs|
puts Geo::ProjectRegistry.failed.find(fgs).project_id
end
```
1. Run the following commands to reset each project's
Geo-related attributes and execute a new sync:
```ruby
failed_geo_syncs.each do |fgs|
registry = Geo::ProjectRegistry.failed.find(fgs)
registry.update(resync_repository: true, force_to_redownload_repository: false, repository_retry_count: 0)
Geo::RepositorySyncService.new(registry.project).execute
end
```
2019-06-21 06:33:37 -04:00
### Very large repositories never successfully synchronize on the **secondary** node
2019-05-05 12:08:21 -04:00
GitLab places a timeout on all repository clones, including project imports
and Geo synchronization operations. If a fresh `git clone` of a repository
2020-07-24 17:09:16 -04:00
on the **primary** takes more than the default three hours, you may be affected by this.
2019-06-21 06:33:37 -04:00
2019-05-05 12:08:21 -04:00
To increase the timeout, add the following line to `/etc/gitlab/gitlab.rb`
on the **secondary** node:
```ruby
2020-07-24 17:09:16 -04:00
gitlab_rails['gitlab_shell_git_timeout'] = 14400
2019-05-05 12:08:21 -04:00
```
Then reconfigure GitLab:
2020-01-30 10:09:15 -05:00
```shell
2019-05-05 12:08:21 -04:00
sudo gitlab-ctl reconfigure
```
2020-07-24 17:09:16 -04:00
This will increase the timeout to four hours (14400 seconds). Choose a time
2019-05-05 12:08:21 -04:00
long enough to accommodate a full clone of your largest repositories.
2020-03-03 19:07:52 -05:00
### New LFS objects are never replicated
If new LFS objects are never replicated to secondary Geo nodes, check the version of
GitLab you are running. GitLab versions 11.11.x or 12.0.x are affected by
2020-05-21 02:08:25 -04:00
[a bug that results in new LFS objects not being replicated to Geo secondary nodes ](https://gitlab.com/gitlab-org/gitlab/-/issues/32696 ).
2020-03-03 19:07:52 -05:00
To resolve the issue, upgrade to GitLab 12.1 or newer.
2020-12-07 04:09:42 -05:00
### Failures during backfill
During a [backfill ](../index.md#backfill ), failures are scheduled to be retried at the end
of the backfill queue, therefore these failures only clear up **after** the backfill completes.
2019-08-06 20:42:29 -04:00
### Resetting Geo **secondary** node replication
2019-05-05 12:08:21 -04:00
If you get a **secondary** node in a broken state and want to reset the replication state,
to start again from scratch, there are a few steps that can help you:
1. Stop Sidekiq and the Geo LogCursor
2019-07-02 21:37:27 -04:00
It's possible to make Sidekiq stop gracefully, but making it stop getting new jobs and
wait until the current jobs to finish processing.
2019-05-05 12:08:21 -04:00
2019-07-02 21:37:27 -04:00
You need to send a **SIGTSTP** kill signal for the first phase and them a **SIGTERM**
when all jobs have finished. Otherwise just use the `gitlab-ctl stop` commands.
2019-05-05 12:08:21 -04:00
2020-01-30 10:09:15 -05:00
```shell
2019-07-02 21:37:27 -04:00
gitlab-ctl status sidekiq
# run: sidekiq: (pid 10180) < - this is the PID you will use
kill -TSTP 10180 # change to the correct PID
2019-05-05 12:08:21 -04:00
2019-07-02 21:37:27 -04:00
gitlab-ctl stop sidekiq
gitlab-ctl stop geo-logcursor
```
2019-05-05 12:08:21 -04:00
2019-09-23 02:06:19 -04:00
You can watch Sidekiq logs to know when Sidekiq jobs processing have finished:
2019-05-05 12:08:21 -04:00
2020-01-30 10:09:15 -05:00
```shell
2019-07-02 21:37:27 -04:00
gitlab-ctl tail sidekiq
```
2019-05-05 12:08:21 -04:00
2019-11-18 04:06:43 -05:00
1. Rename repository storage folders and create new ones. If you are not concerned about possible orphaned directories and files, then you can simply skip this step.
2019-05-05 12:08:21 -04:00
2020-01-30 10:09:15 -05:00
```shell
2019-07-02 21:37:27 -04:00
mv /var/opt/gitlab/git-data/repositories /var/opt/gitlab/git-data/repositories.old
mkdir -p /var/opt/gitlab/git-data/repositories
chown git:git /var/opt/gitlab/git-data/repositories
```
2019-05-05 12:08:21 -04:00
2020-12-07 22:09:37 -05:00
NOTE:
2019-07-02 21:37:27 -04:00
You may want to remove the `/var/opt/gitlab/git-data/repositories.old` in the future
as soon as you confirmed that you don't need it anymore, to save disk space.
2019-05-05 12:08:21 -04:00
1. _(Optional)_ Rename other data folders and create new ones
2020-12-04 16:09:29 -05:00
WARNING:
2019-07-02 21:37:27 -04:00
You may still have files on the **secondary** node that have been removed from **primary** node but
removal have not been reflected. If you skip this step, they will never be removed
from this Geo node.
2019-05-05 12:08:21 -04:00
2019-07-02 21:37:27 -04:00
Any uploaded content like file attachments, avatars or LFS objects are stored in a
subfolder in one of the two paths below:
2019-05-05 12:08:21 -04:00
2019-09-23 02:06:19 -04:00
- `/var/opt/gitlab/gitlab-rails/shared`
- `/var/opt/gitlab/gitlab-rails/uploads`
2019-05-05 12:08:21 -04:00
2019-07-02 21:37:27 -04:00
To rename all of them:
2019-05-05 12:08:21 -04:00
2020-01-30 10:09:15 -05:00
```shell
2019-07-02 21:37:27 -04:00
gitlab-ctl stop
2019-05-05 12:08:21 -04:00
2019-07-02 21:37:27 -04:00
mv /var/opt/gitlab/gitlab-rails/shared /var/opt/gitlab/gitlab-rails/shared.old
mkdir -p /var/opt/gitlab/gitlab-rails/shared
2019-05-05 12:08:21 -04:00
2019-07-02 21:37:27 -04:00
mv /var/opt/gitlab/gitlab-rails/uploads /var/opt/gitlab/gitlab-rails/uploads.old
mkdir -p /var/opt/gitlab/gitlab-rails/uploads
2019-12-06 01:07:34 -05:00
2021-05-12 08:10:24 -04:00
gitlab-ctl start postgresql
2019-12-06 01:07:34 -05:00
gitlab-ctl start geo-postgresql
2019-07-02 21:37:27 -04:00
```
2019-05-05 12:08:21 -04:00
2020-09-30 17:10:09 -04:00
Reconfigure to recreate the folders and make sure permissions and ownership
are correct:
2019-05-05 12:08:21 -04:00
2020-01-30 10:09:15 -05:00
```shell
2019-07-02 21:37:27 -04:00
gitlab-ctl reconfigure
```
2019-05-05 12:08:21 -04:00
1. Reset the Tracking Database
2020-01-30 10:09:15 -05:00
```shell
2020-04-06 23:09:15 -04:00
gitlab-rake geo:db:drop # on a secondary app node
gitlab-ctl reconfigure # on the tracking database node
gitlab-rake geo:db:setup # on a secondary app node
2019-07-02 21:37:27 -04:00
```
2019-05-05 12:08:21 -04:00
1. Restart previously stopped services
2020-01-30 10:09:15 -05:00
```shell
2019-07-02 21:37:27 -04:00
gitlab-ctl start
```
2019-05-05 12:08:21 -04:00
2020-01-27 22:08:39 -05:00
## Fixing errors during a failover or when promoting a secondary to a primary node
The following are possible errors that might be encountered during failover or
when promoting a secondary to a primary node with strategies to resolve them.
### Message: ActiveRecord::RecordInvalid: Validation failed: Name has already been taken
When [promoting a **secondary** node ](../disaster_recovery/index.md#step-3-promoting-a-secondary-node ),
you might encounter the following error:
2020-03-05 22:08:08 -05:00
```plaintext
2020-01-27 22:08:39 -05:00
Running gitlab-rake geo:set_secondary_as_primary...
rake aborted!
ActiveRecord::RecordInvalid: Validation failed: Name has already been taken
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/tasks/geo.rake:236:in `block (3 levels) in < top ( required ) > '
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/tasks/geo.rake:221:in `block (2 levels) in < top ( required ) > '
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `< main > '
Tasks: TOP => geo:set_secondary_as_primary
(See full trace by running task with --trace)
You successfully promoted this node!
```
If you encounter this message when running `gitlab-rake geo:set_secondary_as_primary`
or `gitlab-ctl promote-to-primary-node` , either:
- Enter a Rails console and run:
2020-02-25 04:09:10 -05:00
2020-01-27 22:08:39 -05:00
```ruby
Rails.application.load_tasks; nil
2020-06-04 08:08:21 -04:00
Gitlab::Geo.expire_cache!
2020-01-27 22:08:39 -05:00
Rake::Task['geo:set_secondary_as_primary'].invoke
```
- Upgrade to GitLab 12.6.3 or newer if it is safe to do so. For example,
if the failover was just a test. A [caching-related
bug](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/22021) was
fixed.
2020-08-27 08:10:20 -04:00
### Message: ActiveRecord::RecordInvalid: Validation failed: Enabled Geo primary node cannot be disabled
2020-08-13 05:10:09 -04:00
2020-09-16 05:09:43 -04:00
If you disabled a secondary node, either with the [replication pause task ](../index.md#pausing-and-resuming-replication )
2020-10-18 11:08:49 -04:00
(13.2) or by using the user interface (13.1 and earlier), you must first
re-enable the node before you can continue. This is fixed in 13.4.
2020-09-16 05:09:43 -04:00
2020-10-18 11:08:49 -04:00
Run the following command, replacing `https://<secondary url>/` with the URL
for your secondary server, using either `http` or `https` , and ensuring that you
end the URL with a slash (`/`):
2020-09-16 05:09:43 -04:00
```shell
2020-10-18 11:08:49 -04:00
sudo gitlab-rails dbconsole
UPDATE geo_nodes SET enabled = true WHERE url = 'https://< secondary url > /' AND enabled = false;"
2020-09-16 05:09:43 -04:00
```
This should update 1 row.
2020-05-07 08:09:46 -04:00
### Message: ``NoMethodError: undefined method `secondary?' for nil:NilClass``
When [promoting a **secondary** node ](../disaster_recovery/index.md#step-3-promoting-a-secondary-node ),
you might encounter the following error:
```plaintext
sudo gitlab-rake geo:set_secondary_as_primary
rake aborted!
NoMethodError: undefined method `secondary?' for nil:NilClass
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/tasks/geo.rake:232:in `block (3 levels) in < top ( required ) > '
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/tasks/geo.rake:221:in `block (2 levels) in < top ( required ) > '
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `< main > '
Tasks: TOP => geo:set_secondary_as_primary
(See full trace by running task with --trace)
```
This command is intended to be executed on a secondary node only, and this error
is displayed if you attempt to run this command on a primary node.
2020-03-11 23:10:15 -04:00
### Message: `sudo: gitlab-pg-ctl: command not found`
2020-03-11 20:09:34 -04:00
When
2020-05-20 05:08:11 -04:00
[promoting a **secondary** node with multiple servers ](../disaster_recovery/index.md#promoting-a-secondary-node-with-multiple-servers ),
2020-03-11 20:09:34 -04:00
you need to run the `gitlab-pg-ctl` command to promote the PostgreSQL
read-replica database.
In GitLab 12.8 and earlier, this command will fail with the message:
```plaintext
sudo: gitlab-pg-ctl: command not found
```
In this case, the workaround is to use the full path to the binary, for example:
```shell
sudo /opt/gitlab/embedded/bin/gitlab-pg-ctl promote
```
GitLab 12.9 and later are [unaffected by this error ](https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/5147 ).
2021-01-28 04:09:07 -05:00
### Message: `ERROR - Replication is not up-to-date` during `gitlab-ctl promotion-preflight-checks`
In GitLab 13.7 and earlier, if you have a data type with zero items to sync,
this command reports `ERROR - Replication is not up-to-date` even if
replication is actually up-to-date. This bug was fixed in GitLab 13.8 and
later.
### Message: `ERROR - Replication is not up-to-date` during `gitlab-ctl promote-to-primary-node`
In GitLab 13.7 and earlier, if you have a data type with zero items to sync,
this command reports `ERROR - Replication is not up-to-date` even if
replication is actually up-to-date. If replication and verification output
shows that it is complete, you can add `--skip-preflight-checks` to make the command complete promotion. This bug was fixed in GitLab 13.8 and later.
2021-05-21 14:11:01 -04:00
### Errors when using `--skip-preflight-checks` or `--force`
Before GitLab 13.5, you could bump into one of the following errors when using
`--skip-preflight-checks` or `--force` :
```plaintext
get_ctl_options': invalid option: --skip-preflight-checks (OptionParser::InvalidOption)
get_ctl_options': invalid option: --force (OptionParser::InvalidOption)
```
This can happen with XFS or filesystems that list files in lexical order, because the
load order of the Omnibus command files can be different than expected, and a global function would get redefined.
More details can be found in [the related issue ](https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6076 ).
The workaround is to manually run the preflight checks and promote the database, by running
the following commands on the Geo secondary site:
```shell
sudo gitlab-ctl promotion-preflight-checks
sudo /opt/gitlab/embedded/bin/gitlab-pg-ctl promote
sudo gitlab-ctl reconfigure
sudo gitlab-rake geo:set_secondary_as_primary
2019-06-13 17:07:59 -04:00
## Expired artifacts
If you notice for some reason there are more artifacts on the Geo
2020-03-31 08:08:09 -04:00
secondary node than on the Geo primary node, you can use the Rake task
2019-06-13 17:07:59 -04:00
to [cleanup orphan artifact files ](../../../raketasks/cleanup.md#remove-orphan-artifact-files ).
On a Geo **secondary** node, this command will also clean up all Geo
registry record related to the orphan files on disk.
2019-10-24 02:07:07 -04:00
## Fixing sign in errors
### Message: The redirect URI included is not valid
If you are able to log in to the **primary** node, but you receive this error
when attempting to log into a **secondary** , you should check that the Geo
node's URL matches its external URL.
2020-07-29 20:09:53 -04:00
1. On the primary, visit **Admin Area > Geo** .
2019-10-24 02:07:07 -04:00
1. Find the affected **secondary** and click **Edit** .
1. Ensure the **URL** field matches the value found in `/etc/gitlab/gitlab.rb`
in `external_url "https://gitlab.example.com"` on the frontend server(s) of
the **secondary** node.
2019-06-21 06:33:37 -04:00
## Fixing common errors
2021-02-15 19:09:01 -05:00
This section documents common errors reported in the Admin Area and how to fix them.
2019-05-26 20:37:41 -04:00
### Geo database configuration file is missing
GitLab cannot find or doesn't have permission to access the `database_geo.yml` configuration file.
In an Omnibus GitLab installation, the file should be in `/var/opt/gitlab/gitlab-rails/etc` .
If it doesn't exist or inadvertent changes have been made to it, run `sudo gitlab-ctl reconfigure` to restore it to its correct state.
2020-11-09 19:08:52 -05:00
If this path is mounted on a remote volume, ensure your volume configuration
has the correct permissions.
2019-05-26 20:37:41 -04:00
2019-08-06 20:42:29 -04:00
### An existing tracking database cannot be reused
Geo cannot reuse an existing tracking database.
It is safest to use a fresh secondary, or reset the whole secondary by following
[Resetting Geo secondary node replication ](#resetting-geo-secondary-node-replication ).
2019-08-28 02:06:34 -04:00
### Geo node has a database that is writable which is an indication it is not configured for replication with the primary node
2019-05-26 20:37:41 -04:00
This error refers to a problem with the database replica on a **secondary** node,
which Geo expects to have access to. It usually means, either:
- An unsupported replication method was used (for example, logical replication).
2020-09-17 11:09:24 -04:00
- The instructions to setup a [Geo database replication ](../setup/database.md ) were not followed correctly.
2020-05-14 11:08:14 -04:00
- Your database connection details are incorrect, that is you have specified the wrong
user in your `/etc/gitlab/gitlab.rb` file.
2019-05-26 20:37:41 -04:00
A common source of confusion with **secondary** nodes is that it requires two separate
PostgreSQL instances:
- A read-only replica of the **primary** node.
- A regular, writable instance that holds replication metadata. That is, the Geo tracking database.
2019-08-28 02:06:34 -04:00
### Geo node does not appear to be replicating the database from the primary node
2019-05-26 20:37:41 -04:00
The most common problems that prevent the database from replicating correctly are:
- **Secondary** nodes cannot reach the **primary** node. Check credentials, firewall rules, etc.
- SSL certificate problems. Make sure you copied `/etc/gitlab/gitlab-secrets.json` from the **primary** node.
- Database storage disk is full.
- Database replication slot is misconfigured.
- Database is not using a replication slot or another alternative and cannot catch-up because WAL files were purged.
2020-09-17 11:09:24 -04:00
Make sure you follow the [Geo database replication ](../setup/database.md ) instructions for supported configuration.
2019-05-26 20:37:41 -04:00
### Geo database version (...) does not match latest migration (...)
2020-04-29 23:09:32 -04:00
If you are using Omnibus GitLab installation, something might have failed during upgrade. You can:
2019-05-26 20:37:41 -04:00
2019-06-21 06:33:37 -04:00
- Run `sudo gitlab-ctl reconfigure` .
2019-05-26 20:37:41 -04:00
- Manually trigger the database migration by running: `sudo gitlab-rake geo:db:migrate` as root on the **secondary** node.
2019-09-18 10:02:45 -04:00
### GitLab indicates that more than 100% of repositories were synced
This can be caused by orphaned records in the project registry. You can clear them
[using a Rake task ](../../../administration/raketasks/geo.md#remove-orphaned-project-registries ).
2019-12-03 22:06:22 -05:00
### Geo Admin Area returns 404 error for a secondary node
Sometimes `sudo gitlab-rake gitlab:geo:check` indicates that the **secondary** node is
healthy, but a 404 error for the **secondary** node is returned in the Geo Admin Area on
the **primary** node.
To resolve this issue:
- Try restarting the **secondary** using `sudo gitlab-ctl restart` .
- Check `/var/log/gitlab/gitlab-rails/geo.log` to see if the **secondary** node is
using IPv6 to send its status to the **primary** node. If it is, add an entry to
the **primary** node using IPv4 in the `/etc/hosts` file. Alternatively, you should
2020-02-25 04:09:10 -05:00
[enable IPv6 on the **primary** node ](https://docs.gitlab.com/omnibus/settings/nginx.html#setting-the-nginx-listen-address-or-addresses ).
2020-10-29 14:09:11 -04:00
2021-05-20 11:10:13 -04:00
### Geo Admin Area shows 'Unknown' for health status and 'Request failed with status code 401'
If using a load balancer, ensure that the load balancer's URL is set as the `external_url` in the
`/etc/gitlab/gitlab.rb` of the nodes behind the load balancer.
2021-05-06 14:10:06 -04:00
### GitLab Pages return 404 errors after promoting
This is due to [Pages data not being managed by Geo ](datatypes.md#limitations-on-replicationverification ).
Find advice to resolve those errors in the
[Pages administration documentation ](../../../administration/pages/index.md#404-error-after-promoting-a-geo-secondary-to-a-primary-node ).
2020-10-29 14:09:11 -04:00
## Fixing client errors
### Authorization errors from LFS HTTP(s) client requests
You may have problems if you're running a version of [Git LFS ](https://git-lfs.github.com/ ) before 2.4.2.
As noted in [this authentication issue ](https://github.com/git-lfs/git-lfs/issues/3025 ),
requests redirected from the secondary to the primary node do not properly send the
Authorization header. This may result in either an infinite `Authorization <-> Redirect`
loop, or Authorization errors.