<div dir="ltr">Ok. So if I understand it correctly, every update operation we do could result in a deadlock then? Or is it just ones with "where" criteria that became invalid.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 16, 2015 at 8:58 PM, Carl Baldwin <span dir="ltr"><<a href="mailto:carl@ecbaldwin.net" target="_blank">carl@ecbaldwin.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Jun 16, 2015 at 5:17 PM, Kevin Benton <<a href="mailto:blak111@gmail.com">blak111@gmail.com</a>> wrote:<br>
> There seems to be confusion on what causes deadlocks. Can one of you explain<br>
> to me how an optimistic locking strategy (a.k.a. compare-and-swap) results<br>
> in deadlocks?<br>
><br>
> Take the following example where two workers want to update a record:<br>
><br>
> Worker1: "UPDATE items set value=newvalue1 where value=oldvalue"<br>
> Worker2: "UPDATE items set value=newvalue2 where value=oldvalue"<br>
><br>
> Then each worker checks the count of rows affected by the query. The one<br>
> that modified 1 gets to proceed, the one that modified 0 must retry.<br>
<br>
</span>Here's my understanding: In a Galera cluster, if the two are run in<br>
parallel on different masters, then the second one gets a write<br>
certification failure after believing that it had succeeded *and*<br>
reading that 1 row was modified. The transaction -- when it was all<br>
prepared for commit -- is aborted because the server finds out from<br>
the other masters that it doesn't really work. This failure is<br>
manifested as a deadlock error from the server that lost. The code<br>
must catch this "deadlock" error and retry the entire thing.<br>
<br>
I just learned about Mike Bayer's DBFacade from this thread which will<br>
apparently make the db behave as an active/passive for writes which<br>
should clear this up. This is new information to me.<br>
<br>
I hope my understanding is sound and that it makes sense.<br>
<div class="HOEnZb"><div class="h5"><br>
Carl<br>
<br>
__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div>Kevin Benton</div></div>
</div>