Reads not getting sent to replica
wjessop opened this issue · comments
Using Rails 5.0 (tested on 5.1 and 5.2 also) Ruby 2.6.5, and the latest version of distribute_reads.
I've set up my database.yml as below and included the latest distribute_reads
in my Gemfile, but for some reason reads aren't getting sent to the replica, which I can see by tailing the logs of my primary and replica databases. Where should I be looking to diagnose the issue?
[2] pry(main)> distribute_reads{ UserActivity.count } # Runs on the primary
=> 20012
The database config:
development: &default
adapter: postgresql
database: connector_development
encoding: utf8
min_messages: warning
pool: <%= Integer(ENV["DB_POOL"] || 5) %>
reaping_frequency: <%= Integer(ENV["DB_REAPING_FREQUENCY"] || 10) %>
timeout: 5000
variables:
statement_timeout: 5000 # ms
connect_timeout: 1
checkout_timeout: 1
prepared_statements: false
# add a makara subconfig
makara:
# optional id to identify the proxy with this configuration for stickiness
id: postgres
disable_blacklist: true
master_ttl: 5
master_strategy: failover
slave_strategy: round_robin
sticky: false
# list your connections with the override values (they're merged into the top-level config)
# be sure to provide the role if master, role is assumed to be a slave if not provided
connections:
- role: master
name: primary
url: postgres://127.0.0.1:5432
- name: replica
url: postgres://127.0.0.1:5433
Hey @wjessop, it looks likes the config isn't using the Makara adapter. Check out the readme for how database.yml
should look.
Oh, thanks @ankane, I totally missed that!