MySQL with Orchestrator and ProxySQL seems to get out of sync
bubbl opened this issue · comments
This is weird.
You introduced ProxySQL + orchestrator into the setup, yet, the wordpress connects via hosts file entry to one MySQL server only, leaving out orchestrator...
from wp-config.php on both nginx nodes:
/** MySQL hostname */
define( 'DB_HOST', 'DB_1' );
From /etc/hosts file on both nginx nodes:
bash-4.2# cat /etc/hosts
x.x.x.x DB_1 db_1
y.y.y.y DB_2 db_2
This poses several issues:
- unnecessary cost coming out of the fact, there's additional, not used node.
- problems with writing into the database - both nginx services want to write to one, and this can cause problems with writes, breaking replication.
You should either:
- make sure Wordpress connects through proxysql, not directly to 1 node
- get rid of orchestrator and set up the database connection in a more proper way, e.g. using haproxy or proxysql installed on nginx nodes?
I believe this may be related to previous, similar request: #2
Our customers experienced similar issues with being thrown out of wordpress admin.
We've noticed MySQL was constantly going out of sync and replication being broken all the time.
Hello! Thank you for the notes.
Proxysql node shouldn't be avail in the topology. It is added by mysql autoclustering when creating the topology, with 2 or more nodes mysql in the layer. Also, autoclustering configured master-slave replication by default, contrary to master-master, which is used by cluster. I disabled autoclustering from the topology while creation of wordpress-cluster.
Connect with DB is implemented via HyperDB plugin, where DB_1 and DB_2 are described.
https://github.com/jelastic-jps/wordpress-cluster/blob/master/configs/wordpress/db-config.php#L217
https://github.com/jelastic-jps/wordpress-cluster/blob/master/configs/wordpress/db-config.php#L228
When one of the sql-nodes is down, cluster will be up and running.
Proxysql is being tested at the moment.
Thanks,
Hmm... that is weird, as wp-config has
/** MySQL hostname */
define( 'DB_HOST', 'DB_1' );
at least on our installations, how is that file (db-config.php) overriding wp-config?
And still, somehow wordpress tends to break replication with primary key violations on data import...
Hi,
To be honest, I believe that what you're missing is MySQL config parameters:
auto_increment_increment
auto_increment_offset
Those should make autoincrement work sanely with master-master.