[Pacemaker] can we update an attribute with cmpxchg "atomic compare and exchange" semantics?

Lars Ellenberg lars.ellenberg at linbit.com
Tue Sep 30 09:31:11 EDT 2014


On Tue, Sep 30, 2014 at 01:51:21PM +1000, Andrew Beekhof wrote:
> 
> On 30 Sep 2014, at 6:22 am, Lars Ellenberg <Lars.Ellenberg at linbit.com> wrote:
> 
> > On Wed, Sep 10, 2014 at 11:50:58AM +0200, Lars Ellenberg wrote:
> >> 
> >> Hi Andrew (and others).
> >> 
> >> For a certain use case (yes, I'm talking about DRBD "peer-fencing" on
> >> loss of replication link), it would be nice to be able to say:
> >> 
> >>  update some_attribute=some_attribute+1 where some_attribute >= 0
> >> 
> >>  delete some_attribute where some_attribute=0
> >> 
> >> Ok, that's not the classic cmpxchg(), more of an atomic_add();
> >> or similar enough. With hopefully just a single cib roundrip.
> >> 
> >> 
> >> Let me rephrase:
> >> Update attribute "this_is_pink" (for node-X with ID attr-ID):
> >> 
> >>  fail if said attr-ID exists elsewhere (not as the intended attribute
> >>  at the intended place in the xml tree)
> >> 	(this comes for free already, I think)
> >>  	
> >>  if it does not exist at all, assume it was present with current value 0
> >> 
> >>  if the current (or assumed current) value is >= 0, add 1
> >> 
> >>  if the current value is < 0, fail
> >> 
> >>  (optionally: return new value? old value?)
> > 
> > Did anyone read this?
> 
> Yep, but it requires a non-trivial answer so it got deferred :)
> 
> Its a reasonable request, we've spoken about something similar in the past and its clear that at some point attrd needs to grow some extra capabilities.
> Exactly when it will bubble up to the top of the todo list is less certain, though I would happily coach someone with the necessary motivation.
> 
> The other thing to mention is that currently the only part that wont work is "if the current value is < 0, fail".
> Setting value="value++" will do the rest.

Nice.

> So my question would be... how important is the 'lt 0' case?
> 
> Actually, come to think of it, it's not a bad default behaviour.  
> Certainly failing value++ if value=-INFINITY would be logically consistent with the existing code.
> Would that be sufficient?
> 

I need to think about that some more.
I may need to actually try this out and try to implement my scenario.


-- 
: Lars Ellenberg
: LINBIT | Your Way to High Availability
: DRBD/HA support and consulting http://www.linbit.com

DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.




More information about the Pacemaker mailing list