ryandotsmith/queue_classic — Issue #28: lock_head never locks position 0 when using random offsets
Author: cpisto
Created: 2011-12-01 17:15:51+00:00
State: open

The random offset selection code has a tiny order of operations related bug:

it should be:

SELECT TRUNC(random() * (top_boundary + 1)) INTO relative_top;

so that the possible results are [0..top_boundary] inclusive.

The way it is written now:

SELECT TRUNC(random() * top_boundary + 1) INTO relative_top;

results in [1..top_boundary]