Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seems broken on Rails 7.1 #386

Open
lloydwatkin opened this issue Mar 18, 2024 · 1 comment
Open

Seems broken on Rails 7.1 #386

lloydwatkin opened this issue Mar 18, 2024 · 1 comment

Comments

@lloydwatkin
Copy link

lloydwatkin commented Mar 18, 2024

We've just rolled out Makara on Rails 7.1, unfortunately it appears broken with all requests going to the primary server.

Raising in case any one else plans on rolling out. If anyone else has experienced the same and has a fix please do let me know 👍

Updates

If acting on the base connection everything seems to work ok:

irb(main):001> ActiveRecord::Base.connection.execute('select 1').to_a
  [replica/1] (24.7ms)  select 1
=> [[1]]
irb(main):002> ActiveRecord::Base.connection.execute('update users set first_name= upper(first_name) where id = 1').to_a
  [primary/1] (7.3ms)  update users set first_name= upper(first_name) where id = 1
=> []
irb(main):003> ActiveRecord::Base.connection.execute('select 1').to_a
  [primary/1] (1.6ms)  select 1
=> [[1]]
irb(main):004> Makara::Context.release_all
=> {}
irb(main):005> ActiveRecord::Base.connection.execute('select 1').to_a
  [replica/1] (2.3ms)  select 1
=> [[1]]

It only when working with models that issues occur...

irb(main):009> User.first
  [primary/1] User Load (3.1ms)  SELECT `users`.`id`, `users`.`first_name` FROM `users` WHERE `users`.`deleted_at` IS NULL ORDER BY `users`.`id` ASC LIMIT 1
=> #<User id: 1, first_name: "TOM">
irb(main):010> User.first.update(first_name: 'Test')
  [primary/1] User Load (1.6ms)  SELECT `users`.`id`, `users`.`first_name` FROM `users` WHERE `users`.`deleted_at` IS NULL ORDER BY `users`.`id` ASC LIMIT 1
  [primary/1] TRANSACTION (0.7ms)  BEGIN
  [primary/1] User Update (0.9ms)  UPDATE `users` SET `users`.`first_name` = 'Test', `users`.`updated_at` = '2024-03-20 17:43:24' WHERE `users`.`id` = 1
  [primary/1] TRANSACTION (2.7ms)  COMMIT
=> true
irb(main):011> User.first
  [primary/1] User Load (2.8ms)  SELECT `users`.`id`, `users`.`first_name` FROM `users` WHERE `users`.`deleted_at` IS NULL ORDER BY `users`.`id` ASC LIMIT 1
=> #<User id: 1, first_name: "Test">
irb(main):012> Makara::Context.release_all
=> {}
irb(main):013> User.first
  [primary/1] User Load (3.0ms)  SELECT `users`.`id`, `users`.`first_name` FROM `users` WHERE `users`.`deleted_at` IS NULL ORDER BY `users`.`id` ASC LIMIT 1
=> #<User id: 1, first_name: "Test">
@lloydwatkin
Copy link
Author

If its of interest we ended up creating our own read/write proxy which supports Rails 7.1+.

It doesn't have blocklists or multiple replica connections since, for us, this is handled by AWS RDS/Aurora read/write endpoints.

It can be found here https://github.com/OLIOEX/janus-ar/, version 0.6.0+ is in production for us at olioapp.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant