Commit 88e88a80 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'sh-disable-geo-secondary-writes' into 'master'

Disable DB writes if node is a GitLab Geo secondary instance

See merge request !834
parents 66917e3e ee60ec8d
...@@ -3,6 +3,8 @@ class PruneOldEventsWorker ...@@ -3,6 +3,8 @@ class PruneOldEventsWorker
include CronjobQueue include CronjobQueue
def perform def perform
return if Gitlab::Geo.secondary?
# Contribution calendar shows maximum 12 months of events. # Contribution calendar shows maximum 12 months of events.
# Double nested query is used because MySQL doesn't allow DELETE subqueries # Double nested query is used because MySQL doesn't allow DELETE subqueries
# on the same table. # on the same table.
......
...@@ -168,7 +168,7 @@ module Banzai ...@@ -168,7 +168,7 @@ module Banzai
end end
def update_object(object, html_field, html) def update_object(object, html_field, html)
object.update_column(html_field, html) object.update_column(html_field, html) unless Gitlab::Geo.secondary?
end end
end end
end end
...@@ -39,6 +39,13 @@ describe Banzai::Renderer do ...@@ -39,6 +39,13 @@ describe Banzai::Renderer do
expect_cache_update expect_cache_update
expect(subject).to eq(:html) expect(subject).to eq(:html)
end end
it "skips database caching on a Geo secondary" do
allow(Gitlab::Geo).to receive(:secondary?).and_return(true)
expect_render
expect_cache_update.never
expect(subject).to eq(:html)
end
end end
context "with a filled cache" do context "with a filled cache" do
......
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