[MXS-1549] Aggressive read write split Created: 2017-11-29  Updated: 2018-07-03  Resolved: 2018-07-03

Status: Closed
Project: MariaDB MaxScale
Component/s: readwritesplit
Affects Version/s: None
Fix Version/s: 2.3.0

Type: New Feature Priority: Major
Reporter: dapeng huang Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
is blocked by MXS-1501 Tasks related to transparent master f... Closed
is blocked by MXS-1603 Get trx status from ok packet through... Closed

 Description   

In many cases, application encapsulate all the statements in transactions, so these applications cannot use read write split service which provided by mxs;
In MySQL 5.7 or MariaDB, server provided session track mechanism(https://dev.mysql.com/worklog/task/?id=6631),this mechanism can help divide the statements in a transaction into two groups,the ones which cannot be route to slaves (writes, and the reads after writes), and the another ones which can not be route to slaves(reads before any write);

Proposal:

use SESSION_TRACK_TRANSACTION_CHARACTERISTICS to get current session isolation level;
use SESSION_TRACK_TRANSACTION_STATE to find tranaction boundry;

if current session in RC Mode and "not real in a transacion", and target statment's type is read, so this statment can be route to slave;

mxs can provide a session variable to enable this route behavior;



 Comments   
Comment by markus makela [ 2017-11-29 ]

This requires that a transaction that starts as a read-only transaction can be later applied on the master if it issues a command that causes a transaction to really start.

Comment by dapeng huang [ 2018-01-16 ]

markus makela, we have do a survy on our users who use read write split service, to our surprise,
most of their instances are not scale out properly, the master's qps is greater than sum of all read only replica's qps, there are two reasons:

1. need to keep session read consist, so add hint to route to master, or encapsulate all the statement in a transaction;
2. miss use transaction, most of statements are in transaction, some ORM framework let even worse;

cause this situation is very common among our users, so we need a way to make rwsplit more transparency;

found a worklog maybe helpful, https://dev.mysql.com/worklog/task/?id=6631
for example, the transaction below
BEGIN
SELECT
SELECT
SELECT
INSERT/UPDATE
SELECT
COMMIT;

in RC iso level; we can route first three select to slave, and route DML statement and all the statements behind DML to master;

we found in most cases, read is ahead of write, so this may very useful;
if combine with MXS-199 will be much better

Comment by markus makela [ 2018-01-16 ]

Yes, we have planned to make the readwritesplit more aggressive so that slave servers are utilized to their full capacity. I believe that a good first step would be to implement MXS-199 to some degree and then think of a way to more effectively split the execution of transactions.

A few questions that need to be answered before anything is implemented:

  • Should the slave and master start the transaction at the same time? (pessimistic transaction execution, assume write transactions)
  • Should SELECT statements on slave be done outside of transaction? (would work quite well with MXS-199 and READ COMMITTED)
  • Should the transaction be started on the master before the first select or only when a DML statement is done? (I am not completely sure if this affects the server in some way)
Generated at Thu Feb 08 04:07:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.