Skip to content

Prevent Git operations from checking replication lag on non-Geo-secondary sites

Catalin Irimie requested to merge cat-replication-lag-maintenance-mode into master

What does this MR do and why?

We were checking if the database is read only, and verifying the replication lag, however with the addition of maintenance mode, the read only check is also true when maintenance mode is enabled.

The problem with only using the read only check is two-fold: unnecessary replication lag queries, when the current site is not a secondary, as maintenance mode doesn't pause any DB operations; and breaking databases that don't support the standard replication functions to check the lag (i.e. Aurora).

The replication lag check also does not make sense on non-secondary Geo sites (neither the primary Geo site, nor a non-Geo site)

Related to #342205 (closed).

Screenshots or screen recordings

Not particularly a screenshot, but based on #342205 (closed), a git clone before, on Aurora:

╰─>$ git clone "http://@gdk.test:3000/root/project.git"
Cloning into 'project'...
remote: ActiveRecord::StatementInvalid at /root/project.git/info/refs
remote: ==============================================================
remote:
remote: PG::FeatureNotSupported: ERROR:  Function pg_last_xlog_receive_location() is currently not supported for Aurora
remote:
remote: > To access an interactive console with this error, point your browser to: /__better_errors

After, working as expected:

╰─>$ git clone "http://@gdk.test:3000/root/project.git" test1
Cloning into 'test1'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.

How to set up and validate locally

  1. Enable maintenance mode
  2. Try to clone a repo, grep for pg_last_wal_receive_lsn in log/development.log
  3. Checkout this branch
  4. Try to clone the repo again, notice no more pg_last_wal_receive_lsn queries

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading