@tachybase/plugin-adapter-bullmq 1.3.24 → 1.4.0
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/externalVersion.js +2 -2
- package/dist/node_modules/@bull-board/api/package.json +1 -1
- package/dist/node_modules/@bull-board/koa/dist/index.js +1 -1
- package/dist/node_modules/@bull-board/koa/package.json +1 -1
- package/dist/node_modules/bullmq/dist/cjs/classes/queue.js +4 -2
- package/dist/node_modules/bullmq/dist/cjs/classes/scripts.js +3 -3
- package/dist/node_modules/bullmq/dist/cjs/classes/worker.js +8 -9
- package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveJobToWait.lua +15 -0
- package/dist/node_modules/bullmq/dist/cjs/commands/moveJobFromActiveToWait-9.lua +5 -1
- package/dist/node_modules/bullmq/dist/cjs/commands/moveStalledJobsToWait-8.lua +3 -11
- package/dist/node_modules/bullmq/dist/cjs/commands/{moveToWaitingChildren-8.lua → moveToWaitingChildren-7.lua} +29 -40
- package/dist/node_modules/bullmq/dist/cjs/enums/error-code.js +1 -1
- package/dist/node_modules/bullmq/dist/cjs/index.js +1 -1
- package/dist/node_modules/bullmq/dist/cjs/scripts/index.js +1 -1
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveJobFromActiveToWait-9.js +5 -1
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveStalledJobsToWait-8.js +12 -8
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToWaitingChildren-7.js +107 -0
- package/dist/node_modules/bullmq/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/node_modules/bullmq/dist/cjs/version.js +1 -1
- package/dist/node_modules/bullmq/dist/esm/classes/queue.d.ts +1 -1
- package/dist/node_modules/bullmq/dist/esm/classes/queue.js +4 -2
- package/dist/node_modules/bullmq/dist/esm/classes/scripts.js +3 -3
- package/dist/node_modules/bullmq/dist/esm/classes/worker.js +8 -9
- package/dist/node_modules/bullmq/dist/esm/commands/includes/moveJobToWait.lua +15 -0
- package/dist/node_modules/bullmq/dist/esm/commands/moveJobFromActiveToWait-9.lua +5 -1
- package/dist/node_modules/bullmq/dist/esm/commands/moveStalledJobsToWait-8.lua +3 -11
- package/dist/node_modules/bullmq/dist/esm/commands/{moveToWaitingChildren-8.lua → moveToWaitingChildren-7.lua} +29 -40
- package/dist/node_modules/bullmq/dist/esm/enums/error-code.d.ts +1 -1
- package/dist/node_modules/bullmq/dist/esm/enums/error-code.js +1 -1
- package/dist/node_modules/bullmq/dist/esm/scripts/index.d.ts +1 -1
- package/dist/node_modules/bullmq/dist/esm/scripts/index.js +1 -1
- package/dist/node_modules/bullmq/dist/esm/scripts/moveJobFromActiveToWait-9.js +5 -1
- package/dist/node_modules/bullmq/dist/esm/scripts/moveStalledJobsToWait-8.js +12 -8
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToWaitingChildren-7.js +104 -0
- package/dist/node_modules/bullmq/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/node_modules/bullmq/dist/esm/version.d.ts +1 -1
- package/dist/node_modules/bullmq/dist/esm/version.js +1 -1
- package/dist/node_modules/bullmq/package.json +1 -1
- package/package.json +6 -6
- package/dist/node_modules/bullmq/dist/cjs/scripts/moveToWaitingChildren-8.js +0 -529
- package/dist/node_modules/bullmq/dist/esm/scripts/moveToWaitingChildren-8.js +0 -526
- /package/dist/node_modules/bullmq/dist/esm/scripts/{moveToWaitingChildren-8.d.ts → moveToWaitingChildren-7.d.ts} +0 -0
|
@@ -25,6 +25,7 @@ local rcall = redis.call
|
|
|
25
25
|
--- @include "includes/addJobInTargetList"
|
|
26
26
|
--- @include "includes/batches"
|
|
27
27
|
--- @include "includes/getTargetQueueList"
|
|
28
|
+
--- @include "includes/moveJobToWait"
|
|
28
29
|
--- @include "includes/trimEvents"
|
|
29
30
|
|
|
30
31
|
local stalledKey = KEYS[1]
|
|
@@ -73,20 +74,11 @@ if (#stalling > 0) then
|
|
|
73
74
|
-- If this job has been stalled too many times, such as if it crashes the worker, then fail it.
|
|
74
75
|
local stalledCount = rcall("HINCRBY", jobKey, "stc", 1)
|
|
75
76
|
if stalledCount > maxStalledJobCount then
|
|
76
|
-
local jobAttributes = rcall("HMGET", jobKey, "opts", "parent")
|
|
77
|
-
local rawOpts = jobAttributes[1]
|
|
78
|
-
local rawParentData = jobAttributes[2]
|
|
79
|
-
local opts = cjson.decode(rawOpts)
|
|
80
|
-
|
|
81
77
|
local failedReason = "job stalled more than allowable limit"
|
|
82
78
|
rcall("HSET", jobKey, "defa", failedReason)
|
|
83
79
|
end
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
-- Move the job back to the wait queue, to immediately be picked up by a waiting worker.
|
|
87
|
-
addJobInTargetList(target, markerKey, "RPUSH", isPausedOrMaxed, jobId)
|
|
88
|
-
|
|
89
|
-
rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId", jobId, 'prev', 'active')
|
|
80
|
+
moveJobToWait(metaKey, activeKey, waitKey, pausedKey, markerKey, eventStreamKey, jobId,
|
|
81
|
+
"RPUSH")
|
|
90
82
|
|
|
91
83
|
-- Emit the stalled event
|
|
92
84
|
rcall("XADD", eventStreamKey, "*", "event", "stalled", "jobId", jobId)
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
KEYS[4] job dependencies key
|
|
9
9
|
KEYS[5] job unsuccessful key
|
|
10
10
|
KEYS[6] stalled key
|
|
11
|
-
KEYS[7]
|
|
12
|
-
KEYS[8] events key
|
|
11
|
+
KEYS[7] events key
|
|
13
12
|
|
|
14
13
|
ARGV[1] token
|
|
15
14
|
ARGV[2] child key
|
|
@@ -23,6 +22,7 @@
|
|
|
23
22
|
-1 - Missing job.
|
|
24
23
|
-2 - Missing lock
|
|
25
24
|
-3 - Job not in active set
|
|
25
|
+
-9 - Job has failed children
|
|
26
26
|
]]
|
|
27
27
|
local rcall = redis.call
|
|
28
28
|
local activeKey = KEYS[1]
|
|
@@ -31,71 +31,60 @@ local jobKey = KEYS[3]
|
|
|
31
31
|
local jobDependenciesKey = KEYS[4]
|
|
32
32
|
local jobUnsuccessfulKey = KEYS[5]
|
|
33
33
|
local stalledKey = KEYS[6]
|
|
34
|
-
local
|
|
34
|
+
local eventStreamKey = KEYS[7]
|
|
35
|
+
local token = ARGV[1]
|
|
35
36
|
local timestamp = ARGV[3]
|
|
36
37
|
local jobId = ARGV[4]
|
|
37
38
|
|
|
38
39
|
--- Includes
|
|
39
|
-
--- @include "includes/moveChildFromDependenciesIfNeeded"
|
|
40
|
-
--- @include "includes/removeDeduplicationKeyIfNeededOnFinalization"
|
|
41
|
-
--- @include "includes/removeJobsOnFail"
|
|
42
40
|
--- @include "includes/removeLock"
|
|
43
41
|
|
|
44
|
-
local function
|
|
45
|
-
|
|
46
|
-
local
|
|
42
|
+
local function removeJobFromActive(activeKey, stalledKey, jobKey, jobId,
|
|
43
|
+
token)
|
|
44
|
+
local errorCode = removeLock(jobKey, stalledKey, token, jobId)
|
|
45
|
+
if errorCode < 0 then
|
|
46
|
+
return errorCode
|
|
47
|
+
end
|
|
47
48
|
|
|
48
49
|
local numRemovedElements = rcall("LREM", activeKey, -1, jobId)
|
|
49
50
|
|
|
50
|
-
if
|
|
51
|
+
if numRemovedElements < 1 then
|
|
51
52
|
return -3
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
rcall("ZADD", waitingChildrenKey, score, jobId)
|
|
55
|
-
|
|
56
55
|
return 0
|
|
57
56
|
end
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
local failedReason = "children are failed"
|
|
67
|
-
rcall("ZADD", failedKey, timestamp, jobId)
|
|
68
|
-
rcall("HSET", jobKey, "finishedOn", timestamp)
|
|
69
|
-
rcall("XADD", KEYS[8], "*", "event", "failed", "jobId", jobId, "failedReason",
|
|
70
|
-
failedReason, "prev", "active")
|
|
58
|
+
local function moveToWaitingChildren(activeKey, waitingChildrenKey, stalledKey, eventStreamKey,
|
|
59
|
+
jobKey, jobId, timestamp, token)
|
|
60
|
+
local errorCode = removeJobFromActive(activeKey, stalledKey, jobKey, jobId, token)
|
|
61
|
+
if errorCode < 0 then
|
|
62
|
+
return errorCode
|
|
63
|
+
end
|
|
71
64
|
|
|
72
|
-
|
|
73
|
-
local rawOpts = jobAttributes[3]
|
|
74
|
-
local opts = cjson.decode(rawOpts)
|
|
65
|
+
local score = tonumber(timestamp)
|
|
75
66
|
|
|
76
|
-
|
|
67
|
+
rcall("ZADD", waitingChildrenKey, score, jobId)
|
|
68
|
+
rcall("XADD", eventStreamKey, "*", "event", "waiting-children", "jobId", jobId, 'prev', 'active')
|
|
77
69
|
|
|
78
|
-
|
|
70
|
+
return 0
|
|
71
|
+
end
|
|
79
72
|
|
|
80
|
-
|
|
73
|
+
if rcall("EXISTS", jobKey) == 1 then
|
|
74
|
+
if rcall("ZCARD", jobUnsuccessfulKey) ~= 0 then
|
|
75
|
+
return -9
|
|
81
76
|
else
|
|
82
77
|
if ARGV[2] ~= "" then
|
|
83
78
|
if rcall("SISMEMBER", jobDependenciesKey, ARGV[2]) ~= 0 then
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return errorCode
|
|
87
|
-
end
|
|
88
|
-
return moveToWaitingChildren(activeKey, waitingChildrenKey, jobId, timestamp)
|
|
79
|
+
return moveToWaitingChildren(activeKey, waitingChildrenKey, stalledKey, eventStreamKey,
|
|
80
|
+
jobKey, jobId, timestamp, token)
|
|
89
81
|
end
|
|
90
82
|
|
|
91
83
|
return 1
|
|
92
84
|
else
|
|
93
85
|
if rcall("SCARD", jobDependenciesKey) ~= 0 then
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return errorCode
|
|
97
|
-
end
|
|
98
|
-
return moveToWaitingChildren(activeKey, waitingChildrenKey, jobId, timestamp)
|
|
86
|
+
return moveToWaitingChildren(activeKey, waitingChildrenKey, stalledKey, eventStreamKey,
|
|
87
|
+
jobKey, jobId, timestamp, token)
|
|
99
88
|
end
|
|
100
89
|
|
|
101
90
|
return 1
|
|
@@ -11,6 +11,6 @@ var ErrorCode;
|
|
|
11
11
|
ErrorCode[ErrorCode["JobLockMismatch"] = -6] = "JobLockMismatch";
|
|
12
12
|
ErrorCode[ErrorCode["ParentJobCannotBeReplaced"] = -7] = "ParentJobCannotBeReplaced";
|
|
13
13
|
ErrorCode[ErrorCode["JobBelongsToJobScheduler"] = -8] = "JobBelongsToJobScheduler";
|
|
14
|
-
ErrorCode[ErrorCode["
|
|
14
|
+
ErrorCode[ErrorCode["JobHasFailedChildren"] = -9] = "JobHasFailedChildren";
|
|
15
15
|
})(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
|
|
16
16
|
//# sourceMappingURL=error-code.js.map
|