Files
ubicloud/spec/lib/sem_snap_spec.rb
Jeremy Evans 863af1b8a4 Do not create a Semaphore if there is no related Strand
This is designed to handle race conditions, where the strand is
deleted between when the object is retrieved and when incr_* is
called.

One caller of Semaphore.incr, SemSnap.incr, relies on the
Semaphore being returned.  Update this method handle the
case where nil is returned by Semaphore.incr.

An alternative approach would be raising an exception for this
case.  That can potentially alert us to cases that pass invalid
strand ids, but it would require more code to handle race
conditions.  We couple have separate methods, one that raised by
default, and another than can be used in cases where we know the
strand id is correct, but want to avoid a race condition.  However,
I'm not sure the complexity is worth it.

While here, omit unnecessary hash values, switch from
create_with_id to create, and explicit dataset call, and unnecessary
explicit receiver.
2025-03-20 13:13:49 -07:00

1.4 KiB