Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Have a think about what's getting written to the binary log.</p> <p>You can't ensure that an order created on a master would have the same sequence generated for it when the transaction is played on a slave - or, what would much more likely, by another master in the cluster. e.g.</p> <pre><code> 0) Node 1 and Node 2 are in sync, NextOrderNumber=100 1) Node 1 receives insert statement wrt order from customer A and assigns order number 100, changes its NextOrderNumber to 101 2) Node 1 writes the settings update to the log 3) Node 1 writes the insert statement to the log 4) Node 2 processes for customer B, asigns order number 100 and increments 5) Node 2 writes the settings update from to the log 6) Node 2 writes the insert statement to the log 7) Nodes 2 reads settings update from the log @2 - Its NextOrderNumber is now 102 8) Node 2 reads insert from log @3, tries to apply it but it fails due to duplicate key 9) Node 1 reads the update @5 - Its nextOrderNumber is also now 102 10) Node1 reads insert from log @6 - but this fails due to duplicate key </code></pre> <p>Now orders 100 on the 2 nodes refer to different data, and there is no order 101. </p> <p>There is a reason that there has been a lot of functionality added to modify the behaviour of auto_increment variables.</p> <p>If you wrap the insert in a procedure - which retrieves a value from the sequence generator then embeds it in the insert statement the immediate problem will be resolved, however you need to think about how you avoid assigning the same number twice using different database nodes. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload