bullmq 1.77.0 → 1.77.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/commands/includes/removeJob.lua +1 -1
- package/dist/cjs/commands/includes/removeParentDependencyKey.lua +34 -5
- package/dist/cjs/commands/removeJob-1.lua +23 -14
- package/dist/esm/commands/includes/removeJob.lua +1 -1
- package/dist/esm/commands/includes/removeParentDependencyKey.lua +34 -5
- package/dist/esm/commands/removeJob-1.lua +23 -14
- package/package.json +1 -1
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
local function removeJob(key, hard, baseKey)
|
9
9
|
local jobKey = baseKey .. key
|
10
|
-
removeParentDependencyKey(jobKey, hard, baseKey)
|
10
|
+
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
11
11
|
rcall("DEL", jobKey, jobKey .. ':logs',
|
12
12
|
jobKey .. ':dependencies', jobKey .. ':processed')
|
13
13
|
end
|
@@ -19,9 +19,10 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
local function removeParentDependencyKey(jobKey, hard, baseKey)
|
23
|
-
|
24
|
-
|
22
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
23
|
+
if parentKey then
|
24
|
+
local parentProcessedKey = parentKey .. ":processed"
|
25
|
+
rcall("HDEL", parentProcessedKey, jobKey)
|
25
26
|
local parentDependenciesKey = parentKey .. ":dependencies"
|
26
27
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
27
28
|
if result > 0 then
|
@@ -34,7 +35,7 @@ local function removeParentDependencyKey(jobKey, hard, baseKey)
|
|
34
35
|
|
35
36
|
if hard then
|
36
37
|
if parentPrefix == baseKey then
|
37
|
-
removeParentDependencyKey(parentKey, hard, baseKey)
|
38
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey)
|
38
39
|
rcall("DEL", parentKey, parentKey .. ':logs',
|
39
40
|
parentKey .. ':dependencies', parentKey .. ':processed')
|
40
41
|
else
|
@@ -45,6 +46,34 @@ local function removeParentDependencyKey(jobKey, hard, baseKey)
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
49
|
+
else
|
50
|
+
local missedParentKey = rcall("HGET", jobKey, "parentKey")
|
51
|
+
if( (type(missedParentKey) == "string") and missedParentKey ~= "" and (rcall("EXISTS", missedParentKey) == 1)) then
|
52
|
+
local parentProcessedKey = missedParentKey .. ":processed"
|
53
|
+
rcall("HDEL", parentProcessedKey, jobKey)
|
54
|
+
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
55
|
+
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
56
|
+
if result > 0 then
|
57
|
+
local pendingDependencies = rcall("SCARD", parentDependenciesKey)
|
58
|
+
if pendingDependencies == 0 then
|
59
|
+
local parentId = getJobIdFromKey(missedParentKey)
|
60
|
+
local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)
|
61
|
+
|
62
|
+
rcall("ZREM", parentPrefix .. "waiting-children", parentId)
|
63
|
+
|
64
|
+
if hard then
|
65
|
+
if parentPrefix == baseKey then
|
66
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
|
67
|
+
rcall("DEL", missedParentKey, missedParentKey .. ':logs',
|
68
|
+
missedParentKey .. ':dependencies', missedParentKey .. ':processed')
|
69
|
+
else
|
70
|
+
moveParentToWait(parentPrefix, parentId)
|
71
|
+
end
|
72
|
+
else
|
73
|
+
moveParentToWait(parentPrefix, parentId, true)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
48
78
|
end
|
49
79
|
end
|
50
|
-
|
@@ -42,35 +42,44 @@ local function isLocked( prefix, jobId)
|
|
42
42
|
return true
|
43
43
|
end
|
44
44
|
|
45
|
-
local function removeJob( prefix, jobId)
|
45
|
+
local function removeJob( prefix, jobId, parentKey)
|
46
46
|
local jobKey = prefix .. jobId;
|
47
47
|
|
48
|
-
removeParentDependencyKey(jobKey)
|
49
|
-
|
50
|
-
rcall("LREM", prefix .. "active", 0, jobId)
|
51
|
-
rcall("LREM", prefix .. "wait", 0, jobId)
|
52
|
-
rcall("ZREM", prefix .. "delayed", jobId)
|
53
|
-
rcall("LREM", prefix .. "paused", 0, jobId)
|
54
|
-
rcall("ZREM", prefix .. "completed", jobId)
|
55
|
-
rcall("ZREM", prefix .. "failed", jobId)
|
56
|
-
rcall("ZREM", prefix .. "priority", jobId)
|
57
|
-
rcall("ZREM", prefix .. "waiting-children", jobId)
|
58
|
-
rcall("DEL", jobKey, jobKey .. ":logs", jobKey .. ":processed")
|
48
|
+
removeParentDependencyKey(jobKey, false, parentKey)
|
59
49
|
|
60
50
|
-- Check if this job has children
|
61
51
|
-- If so, we are going to try to remove the children recursively in deep first way because
|
62
52
|
-- if some job is locked we must exit with and error.
|
53
|
+
--local countProcessed = rcall("HLEN", jobKey .. ":processed")
|
54
|
+
local processed = rcall("HGETALL", jobKey .. ":processed")
|
55
|
+
|
56
|
+
if (#processed > 0) then
|
57
|
+
for i = 1, #processed, 2 do
|
58
|
+
local childJobId = getJobIdFromKey(processed[i])
|
59
|
+
local childJobPrefix = getJobKeyPrefix(processed[i], childJobId)
|
60
|
+
removeJob( childJobPrefix, childJobId, jobKey )
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
63
64
|
local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")
|
64
65
|
if (#dependencies > 0) then
|
65
66
|
for i, childJobKey in ipairs(dependencies) do
|
66
67
|
-- We need to get the jobId for this job.
|
67
68
|
local childJobId = getJobIdFromKey(childJobKey)
|
68
69
|
local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)
|
69
|
-
removeJob( childJobPrefix, childJobId )
|
70
|
+
removeJob( childJobPrefix, childJobId, jobKey )
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
73
|
-
rcall("
|
74
|
+
rcall("LREM", prefix .. "active", 0, jobId)
|
75
|
+
rcall("LREM", prefix .. "wait", 0, jobId)
|
76
|
+
rcall("ZREM", prefix .. "delayed", jobId)
|
77
|
+
rcall("LREM", prefix .. "paused", 0, jobId)
|
78
|
+
rcall("ZREM", prefix .. "completed", jobId)
|
79
|
+
rcall("ZREM", prefix .. "failed", jobId)
|
80
|
+
rcall("ZREM", prefix .. "priority", jobId)
|
81
|
+
rcall("ZREM", prefix .. "waiting-children", jobId)
|
82
|
+
rcall("DEL", jobKey, jobKey .. ":logs", jobKey .. ":dependencies", jobKey .. ":processed")
|
74
83
|
|
75
84
|
-- -- delete keys related to rate limiter
|
76
85
|
-- local limiterIndexTable = KEYS[10] .. ":index"
|
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
local function removeJob(key, hard, baseKey)
|
9
9
|
local jobKey = baseKey .. key
|
10
|
-
removeParentDependencyKey(jobKey, hard, baseKey)
|
10
|
+
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
11
11
|
rcall("DEL", jobKey, jobKey .. ':logs',
|
12
12
|
jobKey .. ':dependencies', jobKey .. ':processed')
|
13
13
|
end
|
@@ -19,9 +19,10 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
local function removeParentDependencyKey(jobKey, hard, baseKey)
|
23
|
-
|
24
|
-
|
22
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
23
|
+
if parentKey then
|
24
|
+
local parentProcessedKey = parentKey .. ":processed"
|
25
|
+
rcall("HDEL", parentProcessedKey, jobKey)
|
25
26
|
local parentDependenciesKey = parentKey .. ":dependencies"
|
26
27
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
27
28
|
if result > 0 then
|
@@ -34,7 +35,7 @@ local function removeParentDependencyKey(jobKey, hard, baseKey)
|
|
34
35
|
|
35
36
|
if hard then
|
36
37
|
if parentPrefix == baseKey then
|
37
|
-
removeParentDependencyKey(parentKey, hard, baseKey)
|
38
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey)
|
38
39
|
rcall("DEL", parentKey, parentKey .. ':logs',
|
39
40
|
parentKey .. ':dependencies', parentKey .. ':processed')
|
40
41
|
else
|
@@ -45,6 +46,34 @@ local function removeParentDependencyKey(jobKey, hard, baseKey)
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
49
|
+
else
|
50
|
+
local missedParentKey = rcall("HGET", jobKey, "parentKey")
|
51
|
+
if( (type(missedParentKey) == "string") and missedParentKey ~= "" and (rcall("EXISTS", missedParentKey) == 1)) then
|
52
|
+
local parentProcessedKey = missedParentKey .. ":processed"
|
53
|
+
rcall("HDEL", parentProcessedKey, jobKey)
|
54
|
+
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
55
|
+
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
56
|
+
if result > 0 then
|
57
|
+
local pendingDependencies = rcall("SCARD", parentDependenciesKey)
|
58
|
+
if pendingDependencies == 0 then
|
59
|
+
local parentId = getJobIdFromKey(missedParentKey)
|
60
|
+
local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)
|
61
|
+
|
62
|
+
rcall("ZREM", parentPrefix .. "waiting-children", parentId)
|
63
|
+
|
64
|
+
if hard then
|
65
|
+
if parentPrefix == baseKey then
|
66
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
|
67
|
+
rcall("DEL", missedParentKey, missedParentKey .. ':logs',
|
68
|
+
missedParentKey .. ':dependencies', missedParentKey .. ':processed')
|
69
|
+
else
|
70
|
+
moveParentToWait(parentPrefix, parentId)
|
71
|
+
end
|
72
|
+
else
|
73
|
+
moveParentToWait(parentPrefix, parentId, true)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
48
78
|
end
|
49
79
|
end
|
50
|
-
|
@@ -42,35 +42,44 @@ local function isLocked( prefix, jobId)
|
|
42
42
|
return true
|
43
43
|
end
|
44
44
|
|
45
|
-
local function removeJob( prefix, jobId)
|
45
|
+
local function removeJob( prefix, jobId, parentKey)
|
46
46
|
local jobKey = prefix .. jobId;
|
47
47
|
|
48
|
-
removeParentDependencyKey(jobKey)
|
49
|
-
|
50
|
-
rcall("LREM", prefix .. "active", 0, jobId)
|
51
|
-
rcall("LREM", prefix .. "wait", 0, jobId)
|
52
|
-
rcall("ZREM", prefix .. "delayed", jobId)
|
53
|
-
rcall("LREM", prefix .. "paused", 0, jobId)
|
54
|
-
rcall("ZREM", prefix .. "completed", jobId)
|
55
|
-
rcall("ZREM", prefix .. "failed", jobId)
|
56
|
-
rcall("ZREM", prefix .. "priority", jobId)
|
57
|
-
rcall("ZREM", prefix .. "waiting-children", jobId)
|
58
|
-
rcall("DEL", jobKey, jobKey .. ":logs", jobKey .. ":processed")
|
48
|
+
removeParentDependencyKey(jobKey, false, parentKey)
|
59
49
|
|
60
50
|
-- Check if this job has children
|
61
51
|
-- If so, we are going to try to remove the children recursively in deep first way because
|
62
52
|
-- if some job is locked we must exit with and error.
|
53
|
+
--local countProcessed = rcall("HLEN", jobKey .. ":processed")
|
54
|
+
local processed = rcall("HGETALL", jobKey .. ":processed")
|
55
|
+
|
56
|
+
if (#processed > 0) then
|
57
|
+
for i = 1, #processed, 2 do
|
58
|
+
local childJobId = getJobIdFromKey(processed[i])
|
59
|
+
local childJobPrefix = getJobKeyPrefix(processed[i], childJobId)
|
60
|
+
removeJob( childJobPrefix, childJobId, jobKey )
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
63
64
|
local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")
|
64
65
|
if (#dependencies > 0) then
|
65
66
|
for i, childJobKey in ipairs(dependencies) do
|
66
67
|
-- We need to get the jobId for this job.
|
67
68
|
local childJobId = getJobIdFromKey(childJobKey)
|
68
69
|
local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)
|
69
|
-
removeJob( childJobPrefix, childJobId )
|
70
|
+
removeJob( childJobPrefix, childJobId, jobKey )
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
73
|
-
rcall("
|
74
|
+
rcall("LREM", prefix .. "active", 0, jobId)
|
75
|
+
rcall("LREM", prefix .. "wait", 0, jobId)
|
76
|
+
rcall("ZREM", prefix .. "delayed", jobId)
|
77
|
+
rcall("LREM", prefix .. "paused", 0, jobId)
|
78
|
+
rcall("ZREM", prefix .. "completed", jobId)
|
79
|
+
rcall("ZREM", prefix .. "failed", jobId)
|
80
|
+
rcall("ZREM", prefix .. "priority", jobId)
|
81
|
+
rcall("ZREM", prefix .. "waiting-children", jobId)
|
82
|
+
rcall("DEL", jobKey, jobKey .. ":logs", jobKey .. ":dependencies", jobKey .. ":processed")
|
74
83
|
|
75
84
|
-- -- delete keys related to rate limiter
|
76
85
|
-- local limiterIndexTable = KEYS[10] .. ":index"
|