title: Galera cluster replication between two data centers
body: <p>We have 4 servers located in two data centers. A direct line connects the two datacenters. We are planning to switch from MariaDB to MariaBD Gallera as circular replication is a pain.</p>
  
  <p>A load-balancer is used to determine which server will handle an incoming request which can be any of the four servers.</p>
  
  <p>My concern is what happens when the connection between the data center is down?
  Will each two centers form a mini cluster until the connection is back and then they reorganize themselves into a 4 node cluster again?</p>
  
  <p>How does Galera prevent primary key duplication issues that may occure when the connection between the two data centers fails? </p>
  
  <p>Imagine that the load-balancer starts forwarding requests to both data centers and inserts take place in both of them which may result in PK duplication issues when the connection come back.</p>
  
  <p><img src="https://i.stack.imgur.com/j14n7.png" alt="enter image description here"></p>
  
  <p>I have tried to simulate the different cases using vmware station however I have no idea how to replicate this case. I have managed to create a 4 node replication cluster and managed to take out and bring nodes into the cluster. However I have no idea how simulate data centers.</p>