0

We are facing intermitent deadlock issues that doesnt got reflected in the maxscale log nor the mariadb log. Only in the applications triying to do sql transactions in the database.

We use mostly readwritesplit with 2 nodes (yes, i know, bad design) and we dont know exactly how maxscale deals with the select for update queries.

  1. to the slave, because is a read query (select)
  2. to the master, because is a write query (update)

Maxscale version 2.1.16, MariaDB 2.1.29

Thanks!

2

It would be routed to the master, because SELECT ... FOR UPDATE is only a part of a transaction, and according to the MaxScale 2.1 readwritesplit documentation, "all statements within an open transaction" are routed to the master.

You should be able to verify this with a query like this, which should consistently give you the hostname of the master:

START TRANSACTION;
SELECT * FROM t1 WHERE id = 1 FOR UPDATE;
SELECT @@hostname;
COMMIT;
1
  • 1
    The example query is good but to be completely sure the routing is correct you want to combine the FOR UPDATE into the @@hostname query: SELECT t1.*, @@hostname FROM t1 WHERE id = 1 FOR UPDATE;. Another option is to enable log_info and look at the logs to see where each query is going. – markusjm Feb 10 '19 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.