title: MySql Master-Master Replication Causing Missing AutoIncrement Values
body: <p>I'm looking for some help with a MySql Master-Master configuration issue.</p>
  
  <p>I'm working on a server config that has been set up by another employee who is now unavailable to offer any assistance in this matter. This is my first experience of a setup such as this and after doing quite a bit of research all I've managed to find is conflicting (or missing!) information. As such I apologise if my question is stupid!</p>
  
  <p>My issue is this:</p>
  
  <p>While the replication is working between servers I have an issue with the way that Auto_Increment values are behaving.</p>
  
  <p>I'm content that the AI Offset and Increment are correctly set:</p>
  
  <pre><code>-- Master1 -- 
  auto_increment_increment = 2
  auto_increment_offset = 1
  
  -- Master2 -- 
  auto_increment_increment = 2
  auto_increment_offset = 2
  </code></pre>
  
  <p>And this currently works correctly (Master 1 has Odd AI_Numbers and Master 2 has Even AI_Numbers). Unfortunately the software that has been using this system only connects to Master 2 if Master 1 fails (which hasn't happened since boot 2 years ago). This means that for the part of the system I've now been tasked with updating we haven't seen an even AI_Number... ever! </p>
  
  <p>Using:</p>
  
  <pre><code>SHOW TABLE STATUS FROM `Database` LIKE 'TableName';
  </code></pre>
  
  <p>I can see that the AI Value is 7765. However this is true for both tables - so even though Master2 has never had an insert run on it directly when the next one is run it will generate 7766 as the AI_Value. My question therefore is this:</p>
  
  <p>Is this expected or should the table in Master2 have a value of 1 (thus generating 2 when an insert is run on it)? If this is expected then is there a way to keep the replication config but only increase the AI_Value of Master2 when an insert is run on it?</p>
  
  <p>Thanks for your help!</p>
  
  <p>Chris</p>