Hello,
I have a Rails app that’s seeing some scale, so I am interested in adding another app machine + a read replica DB in a different part of the world. I’m trying to follow the instructions here: High Availability & Global Replication · Fly Docs
At first glance, things seemed to work. However, when I connect to a Rails console secondary machine attached to the read replica (confirmed by outputting Rails.configuration.database_configuration
), I am still able to save records. Also, when I create records in the front-end, I am not seeing the Rails.info.logger
message that is supposed to print “Replaying Request”:
class ApplicationController < ActionController::Base
rescue_from ActiveRecord::StatementInvalid do |e|
if e.cause.is_a?(PG::ReadOnlySqlTransaction)
r = ENV["PRIMARY_REGION"]
response.headers["fly-replay"] = "region=#{r}"
Rails.logger.info "Replaying request in #{r}"
render plain: "retry in region #{r}", status: 409
else
raise e
end
end
end
I’m out of ideas… Has anyone successfully gotten this to work?