Commit 5c4d0dc6 authored by Andreas Brandl's avatar Andreas Brandl

Merge branch 'sh-handle-nil-replication-lag' into 'master'

Fix background migrations failing with unused replication slot

Closes #63666

See merge request gitlab-org/gitlab-ce!30042
parents 47089be0 d092ed17
......@@ -28,7 +28,7 @@ module Postgresql
# We force the use of a transaction here so the query always goes to the
# primary, even when using the EE DB load balancer.
sizes = transaction { pluck(lag_function) }
too_great = sizes.count { |size| size >= max }
too_great = sizes.compact.count { |size| size >= max }
# If too many replicas are falling behind too much, the availability of a
# GitLab instance might suffer. To prevent this from happening we require
......
---
title: Fix background migrations failing with unused replication slot
merge_request: 30042
author:
type: fixed
......@@ -47,5 +47,13 @@ describe Postgresql::ReplicationSlot, :postgresql do
expect(described_class.lag_too_great?).to eq(false)
end
it 'returns false when there is a nil replication lag' do
expect(described_class)
.to receive(:pluck)
.and_return([0.megabytes, nil])
expect(described_class.lag_too_great?).to eq(false)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment