diff --git a/src/commands/includes/removeDeduplicationKey.lua b/src/commands/includes/removeDeduplicationKey.lua index a4b2a461d7..6325fb6324 100644 --- a/src/commands/includes/removeDeduplicationKey.lua +++ b/src/commands/includes/removeDeduplicationKey.lua @@ -2,8 +2,7 @@ Function to remove deduplication key. ]] -local function removeDeduplicationKey(prefixKey, jobKey) - local deduplicationId = rcall("HGET", jobKey, "deid") +local function removeDeduplicationKey(prefixKey, jobKey, deduplicationId) if deduplicationId then local deduplicationKey = prefixKey .. "de:" .. deduplicationId rcall("DEL", deduplicationKey) diff --git a/src/commands/includes/removeJob.lua b/src/commands/includes/removeJob.lua index 68d2ef1c6e..8396906737 100644 --- a/src/commands/includes/removeJob.lua +++ b/src/commands/includes/removeJob.lua @@ -11,9 +11,11 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey) local jobKey = baseKey .. jobId removeParentDependencyKey(jobKey, hard, nil, baseKey) + local jobAttributes = rcall("HMGET", jobKey, "deid", "chkey") + if shouldRemoveDeduplicationKey then - removeDeduplicationKey(baseKey, jobKey) + removeDeduplicationKey(baseKey, jobKey, jobAttributes[1]) end - removeChainKeyIfNeeded(rcall("HGET", jobKey, "chkey"), jobKey) + removeChainKeyIfNeeded(jobAttributes[2], jobKey) removeJobKeys(jobKey) end diff --git a/src/commands/removeJob-2.lua b/src/commands/removeJob-2.lua index 0d684324d5..489c34c7a0 100644 --- a/src/commands/removeJob-2.lua +++ b/src/commands/removeJob-2.lua @@ -68,8 +68,10 @@ local function removeJob(prefix, jobId, parentKey, removeChildren) local prev = removeJobFromAnyState(prefix, jobId) + local jobAttributes = rcall("HMGET", jobKey, "deid", "chkey") + removeDeduplicationKey(prefix, jobKey) - removeChainKeyIfNeeded(rcall("HGET", jobKey, "chkey"), jobKey) + removeChainKeyIfNeeded(jobAttributes[2], jobKey, jobAttributes[1]) if removeJobKeys(jobKey) > 0 then local maxEvents = getOrSetMaxEvents(KEYS[2]) rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed", "jobId", jobId, "prev",