2

I have just configured database replication in a Rails 6.0 application. It works smoothly, but I am trying to confirm that the right database/role is used for the queries I am expecting it to (long story short: manually calling ActiveRecord::Base.connected_to for business logic reasons).

I Googled and Stack-Overflow-ed that question, but can't seem to find an answer.

Is it possible to have the SQL queries debug entries display the database name and role used?

2021-08-06T13:26:02.186960+00:00 app[web.1]: D, [2021-08-06T13:26:02.186858 #46] DEBUG -- : [c132c761-c02c-4690-a8b0-f8c29d999xxx]   Shop Load (1.6ms)  SELECT "shops".* FROM "shops" WHERE "shops"."slug" = 'some slug' LIMIT 1

If not, what other ways are at my disposal to assert that my replica/follower is being hit instead of the leader/master database?

If it is of any help to answer my question: I am running this on Heroku.

Thank you in advance!

Adeynack
  • 1,200
  • 11
  • 18
  • 1
    reference: https://stackoverflow.com/questions/68539123/include-the-role-of-active-record-queries-in-logs/68556672#68556672 – Lam Phan Aug 06 '21 at 15:30

0 Answers0