Merge branch 'feature/pg-slave-detection' into 'master'
Prevent running CREATE EXTENSION in a slave server When you have replication enabled, you can have for a specific space of time your slave node without all database changes from master. The same can happen when you have an issue with replication. This is not usually a problem to omnibus but as recently we try to enable extensions, we should take extra care that we are not trying to do that on the slave server, as it is running in read-only mode and therefore will fail. It will get this changes from the replication itself, so no harm here. Fixes gitlab-org/gitlab-ee#628 See merge request !829
This commit is contained in:
commit
7821bbaa21
|
@ -69,6 +69,12 @@ class PgHelper
|
|||
"|grep -x #{db_user}"])
|
||||
end
|
||||
|
||||
def is_slave?
|
||||
psql_cmd(["-d 'template1'",
|
||||
"-c 'select pg_is_in_recovery()' -A",
|
||||
"|grep -x t"])
|
||||
end
|
||||
|
||||
def psql_cmd(cmd_list)
|
||||
cmd = ["/opt/gitlab/bin/gitlab-psql", cmd_list.join(" ")].join(" ")
|
||||
success?(cmd)
|
||||
|
|
|
@ -179,5 +179,5 @@ execute "enable pg_trgm extension" do
|
|||
user postgresql_user
|
||||
retries 20
|
||||
action :nothing
|
||||
not_if { !pg_helper.is_running? }
|
||||
not_if { !pg_helper.is_running? || pg_helper.is_slave? }
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue