makara icon indicating copy to clipboard operation
makara copied to clipboard

Queries with inline views dont hit slave

Open mathieuripert opened this issue 7 years ago • 2 comments

sql queries with inline views are redirected to master because they do not match the SQL_SLAVE_MATCHERS here https://github.com/taskrabbit/makara/blob/master/lib/active_record/connection_adapters/makara_abstract_adapter.rb#L112

Example:

with users as (
select id, name from users where active is true
)
select * from users 

this query will be redirected to master, whereas it can be queried on slave. Is there a reason for that that i am missing ?

mathieuripert avatar Nov 28 '17 22:11 mathieuripert

the /A means "start of string" - so there's probably a new regex (or set of them) to write to handle the with case.

bleonard avatar Nov 28 '17 23:11 bleonard

This seems to be addressed like the day before it was reported ><; with 7b1295f3fb5a394d03849f45128c91f94ffbd96f

Seems to work for me anyway.

jackcasey avatar May 21 '18 06:05 jackcasey