Avoid ack() race condition in JobQueueRedis

The race would cause jobs to be be unclaimed but have
no actual job data, causing pop() to return false for
them.

Bug: T133089
Change-Id: Icc60388d4431ab7fa2ca2e46bbb0d212b2b94201
This commit is contained in:
Aaron Schulz 2016-04-20 08:34:55 -07:00 committed by Ori.livneh
parent d1c0589f6d
commit efd8f86283

View file

@ -393,12 +393,17 @@ LUA;
static $script =
<<<LUA
local kClaimed, kAttempts, kData = unpack(KEYS)
local uuid = unpack(ARGV)
local id = unpack(ARGV)
-- Unmark the job as claimed
redis.call('zRem',kClaimed,uuid)
redis.call('hDel',kAttempts,uuid)
local removed = redis.call('zRem',kClaimed,id)
-- Check if the job was recycled
if removed == 0 then
return 0
end
-- Delete the retry data
redis.call('hDel',kAttempts,id)
-- Delete the job data itself
return redis.call('hDel',kData,uuid)
return redis.call('hDel',kData,id)
LUA;
$res = $conn->luaEval( $script,
[