mysqlnd_ms icon indicating copy to clipboard operation
mysqlnd_ms copied to clipboard

Multi-master with round robin reads

Open johnwc opened this issue 5 years ago • 4 comments

I have a Multi-Master mysql 8.0.20 replication setup, and I am using the same config as the example here. But, it does not seem to round robin the selects? I have a simple php page that is doing nothing but querying select @@hostname AS HOST;. Every refresh shows the same hostname, which is the writable master.

How do I get it to round robin?

johnwc avatar Jun 05 '20 05:06 johnwc

Those examples are from original mysqlnd_ms! Did You set mysqlnd_ms.multi_master=1 in your ini file?

sergiotabanelli avatar Jun 06 '20 12:06 sergiotabanelli

I am curious! How do You manage write conflicts in your multi-master setup??

sergiotabanelli avatar Jun 06 '20 12:06 sergiotabanelli

I do have that set. I'm not sure how MySQL 8 replication handles write conflicts in a multi master setup. It seems though that even though it is multi master, only one is writable.

johnwc avatar Jun 06 '20 15:06 johnwc

Sorry, I missed the Every refresh!! That means new connection on every query, so round robin is always restarted, round robin can be applied only on the very same mysql connection! I am pretty sure that You will get same result also for configurations witch include slaves. So if You need to balance distinct connections use random instead of roundrobin.

On write conflicts management

New features of mysqlnd_ms can manage and avoid write conflicts! But it needs a memcached server! Check my gist https://gist.github.com/sergiotabanelli/ce992b630d08a0bc7a9cec7c577638f5 and https://github.com/sergiotabanelli/mysqlnd_ms/blob/master/docs/BOOK/QUICKSTART-AND-EXAMPLES/SERVICE-LEVEL-AND-CONSISTENCY.md

sergiotabanelli avatar Jun 08 '20 11:06 sergiotabanelli