Understanding read-write split.

74 views
Skip to first unread message

Denis Makovkin

unread,
May 20, 2022, 7:27:12 AM5/20/22
to MaxScale
Hello, please, can anyone explain me a little about read/write split.
I've 2 mysql servers, Master-Slave replica, and maxscale with read/write split schema, all seems works good. But errors from my application force me to look a little close to requests splitting. 
Ok, i connect to maxscale with mysql-client and make simle queries:
select.., insert.., seleect.... And i see, that first "select" goes to slave (that's ok), "insert" goes to master (ok too), and the last "select" goes to "slave" again. And it seems to be not OK, because slave is always behind master, and it probably don't have necessary data yet.

Is it possible to route all queries to master after query, that make changes in data ? Or i missing something and search in wrong place? Thanks

Markus Mäkelä

unread,
May 20, 2022, 8:42:08 AM5/20/22
to maxs...@googlegroups.com

Hi,

The causal_reads feature of readwritesplit should help you solve the problem. It will make sure the server has replicated the previous transaction the connection did before proceeding with the SELECT statement. The causal_reads=local mode should be suitable for your use-case.

Remember to add the last_gtid into session_track_system_variables: MaxScale needs this to detect the latest GTID in order for it to be able to instruct the server to wait until that transaction has been replicated.

Markus

--
You received this message because you are subscribed to the Google Groups "MaxScale" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maxscale+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/maxscale/9e649fe5-d4b9-49d8-b986-cdc70906647fn%40googlegroups.com.
-- 
Markus Mäkelä, Senior Software Engineer
MariaDB Corporation

Denis Makovkin

unread,
May 23, 2022, 2:01:57 AM5/23/22
to MaxScale
Thanks a lot, sounds great. 

пятница, 20 мая 2022 г. в 15:42:08 UTC+3, Markus Mäkelä:

Denis Makovkin

unread,
May 23, 2022, 2:18:47 AM5/23/22
to MaxScale
Looks like i can use this feature only with maridb servers, right? it will not work with percona, for example, coz "MariaDB gtid" is not the same as gtid ?
понедельник, 23 мая 2022 г. в 09:01:57 UTC+3, Denis Makovkin:

Markus Mäkelä

unread,
May 23, 2022, 3:50:33 AM5/23/22
to maxs...@googlegroups.com

Hi,

Yes, the feature currently only works with MariaDB GTIDs.

Markus

Reply all
Reply to author
Forward
0 new messages