Distribute reads Makara with Heroku Postgres Not working
punter82 opened this issue · comments
Hello,
I am using heroku Primary follower and configured Makara with distribute reads. I followed all the configurations mentioned in the readme and also what in general others have been using and it all looks fine. I am also using PG bouncer with connection pool. Now my problem is the Read/select queries are not going to replica and it always goes to primary. My database.yml is below
`default: &default
<% if ENV["MASTER_SLAVE_REPLICA"] == 'on' %>
url: postgresql-makara:///
makara:
sticky: true
connections:
- role: master
name: primary
url: <%= ENV["DATABASE_CONNECTION_POOL_URL"] %>
- name: replica
url: <%= ENV["REPLICA_DATABASE_URL"] %>
<% else %>
adapter: postgresql
host: <%= ENV['PGHOST'] %>
username: <%= ENV['POSTGRES_USER'] %>
<% end %>
development:
<<: *default
database: db_name
test:
<<: *default
database: test_db
production:
prepared_statements: false`
I tried having an initializer for distribute reads and added
`DistributeReads.by_default = true
Makara::Cache.store = DistributeReads::CacheStore.new
`
Also tried both distribute_reads(replica: true) do end and distribute_reads do also ensure i am adding the to_a too for some lazy evaluation where queries. No matter what it never goes to replica.
Can someone tell me what i am still missing ?
Hey @punter82, unfortunately, I don't have the bandwidth to help with app-specific issues. Try posting on Stack Overflow.
Curious, @punter82 , this line ... <% if ENV["MASTER_SLAVE_REPLICA"] == 'on' %>
... do you have an ENV variable set for this to evaluate? I'm wondering if this is skipped and you are thus skipping all the code to configure for postgresql-makara. I have a Heroku app I wish to use this on ... but am currently unclear on the configuration. If you've had success, please share. Thanks!