Replies: 3 comments 1 reply
-
You probably would be best off using the |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for the quick response. This is what my team and I have tried today so we are thinking along the same lines. This in particular:
And inside the method...
This, however, does not result in passing tests, which suggests to me most likely that the fetch is still using the :read_only server. I notice in the docs that the examples uses are with db[:some_table_name], but in this case it is a bit different as locking does not involve a specific table. Perhaps that could be the reason. My follow up questions are: 1) Is this the correct way to specify the writer instance for the given scenario? 2) Is there a way to receive feedback from the db about whether it used :default or :read_only for the query it just made? Thanks again! |
Beta Was this translation helpful? Give feedback.
-
Thank you for this! We have solved our problem! I am responding here to explain our findings/confirm with you and make the information available in case anyone else comes to look at this. Logging the connection info showed me three things. The first thing is expressed by these extraneous operations that appear in my log output:
The learning for me here is that the chosen connection for an operation that does not query the database is the reader (59460)! Then, other operations that do truncates against the table as part of db cleaning in our tests use the writer (61380). The second learning is that without
The third learning is that with
|
Beta Was this translation helpful? Give feedback.
-
Hey there 👋
I have recently sought to begin using AWS read replica in addition to the main RDS instance in my Sequel project. I have added this to the database.yml
Totally great! By doing so, I am able to see that SELECT statements begin to hit the replica in AWS after I deploy.
The issue comes when I try to continue using my advisory lock which includes the following code:
I have tried simply specifying (:read_only) for the synchronize which gets my unit tests to pass but then causes all kinds of locking failures in practice. I believe the appropriate solution is to force these specific SELECT statements to instead go back and use the writer db instance. In the use of db.run, I can pass a second parameter {server: :default} to get the job done. However, for db.fetch, there is no option to specify the server, and I cannot switch to using db.run in that case because I need to harness the return value. How might I go about ensuring that db.fetch uses the writer db instance?
Thank you for your time.
Beta Was this translation helpful? Give feedback.
All reactions