mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
DEV: Allow writes to PG even if Redis is readonly mode.
Previously, I thought it was better to drop the site into reading mode when Redis has failed over to the replica but it created more errors while Redis is in readonly mode since ActiveRecord would prevent us from writing to PG even though PG is up.
This commit is contained in:
parent
cebd8da299
commit
031a6616a3
@ -55,16 +55,12 @@ if defined?(RailsFailover::ActiveRecord)
|
|||||||
Discourse.redis.exists?(
|
Discourse.redis.exists?(
|
||||||
Discourse::PG_READONLY_MODE_KEY,
|
Discourse::PG_READONLY_MODE_KEY,
|
||||||
Discourse::PG_FORCE_READONLY_MODE_KEY
|
Discourse::PG_FORCE_READONLY_MODE_KEY
|
||||||
) || (
|
|
||||||
GlobalSetting.redis_config[:replica_host] &&
|
|
||||||
Discourse.redis.connection[:host] == GlobalSetting.redis_config[:replica_host]
|
|
||||||
)
|
)
|
||||||
rescue => e
|
rescue => e
|
||||||
if e.is_a?(Redis::CannotConnectError)
|
if e.is_a?(Redis::CannotConnectError)
|
||||||
true
|
|
||||||
else
|
|
||||||
Rails.logger.warn "#{e.class} #{e.message}: #{e.backtrace.join("\n")}"
|
Rails.logger.warn "#{e.class} #{e.message}: #{e.backtrace.join("\n")}"
|
||||||
false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user