Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit dba.stackexchange
scroll top