Search code examples
maxscale

Prevent the execution of "SET NAMES" on all nodes in MaxScale?


Our current setup has multiple slave nodes and one remote master server located in a different datacenter (with a ~100ms latency)?

Is there any way to configure MaxScale to execute the 'SET NAMES' query (or any other session query) only on the slave it is actually going to read from?

A significant delay is introduced every time it has to wait for the master.


Solution

  • One option that might avoid this in some cases is lazy_connect that defers the creation of connections until they are needed.

    Unfortunately, the way the feature behaves is that if there is a session command that modifies the state of the session and no connections are open, it picks the current master node as the server to execute it on. If you can execute a SELECT statement before the SET NAMES, this could still work in your case. If the SET NAMES or any other session command is the first command to be executed, you'll still pay the cost in latency.

    The reason why lazy_connect does this is to avoid getting the "wrong" answer for the command: when a conflict in session command responses is detected, all servers that returned a different result than the one that was the "accepted answer" will get discarded as their state is no longer consistent.

    There are a few improvements and feature requests in the MariaDB Jira to improve the functionality of readwritesplit when used in this sort of a read-mostly scenario:

    I also filed a new feature request for improving the read-only behavior of lazy_connect in readwritesplit: