I have a multi-nodes Galera setup which is master-master. An API call to a web server A could write data to either database 1, 2, 3 or 4 (we are not using HaProxy). Another API call right after that could hit web server A again. However, the second API call couldn't find the record created in the previous request.

  • Request 1: Hits either WS A or B. It could connect to either DB 1,2,3, or 4. Writes a record into a table with PDO transaction
  • Request 2: Hits either WS A or B. It could connect to either DB 1,2,3, or 4. Tried to get the record created in Request 1 but it's not available.

It's worth noticing that:

  • Both requests were made asynchronously.
  • The record eventually showed up in all nodes (manually checked, so, not sure if it wasn't there when the second request was made)

What am I dealing with here, guys?

1 Answer 1


This answer provided by @Bill Karwin explains how this is one of the drawbacks of Galera Cluster.

What are the drawbacks of using Galera Cluster instead of Master/Slave Replication?

"...Therefore there's still a small chance of reading stale data from another cluster node. There's an option you can set to force SELECT to wait until the queue of worksets has updated the database, but this means you have delays on SELECT..."

Refer to this article on how to force the SELECT to wait for the most up to date data. http://galeracluster.com/2015/06/achieving-read-after-write-semantics-with-galera/

You will need to set the "wsrep_sync_wait" session variable.

  • Hi @chad-cahill, do we need to restart the galera for the new setting taking effect?
    – ln9187
    Commented Aug 1, 2017 at 15:08
  • @ln9187 wsrep_sync_wait is a dynamic variable, so it can be set without a restart. In your case you may want to set this variable = 1. You can set it dynamically from the mysql client using SET GLOBAL wsrep_sync_wait=1; You should also specify it in your my.cnf file so that the change persists even after a restart. In my.cnf add the following line: wsrep_sync_wait=1 Commented Aug 1, 2017 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.