bullmq 5.78.0 → 5.78.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.
@@ -10,6 +10,7 @@
10
10
  KEYS[6] 'paused', (LIST)
11
11
  KEYS[7] 'marker'
12
12
  KEYS[8] 'event stream' (STREAM)
13
+ KEYS[9] 'repeat' key
13
14
 
14
15
  ARGV[1] Max stalled job count
15
16
  ARGV[2] queue.toKey('')
@@ -35,6 +36,7 @@ local metaKey = KEYS[5]
35
36
  local pausedKey = KEYS[6]
36
37
  local markerKey = KEYS[7]
37
38
  local eventStreamKey = KEYS[8]
39
+ local repeatKey = KEYS[9]
38
40
  local maxStalledJobCount = tonumber(ARGV[1])
39
41
  local queueKeyPrefix = ARGV[2]
40
42
  local timestamp = ARGV[3]
@@ -74,12 +76,20 @@ if (#stalling > 0) then
74
76
  local stalledCount = rcall("HINCRBY", jobKey, "stc", 1)
75
77
 
76
78
  -- Check if this is a repeatable job by looking at job options
77
- local jobOpts = rcall("HGET", jobKey, "opts")
79
+ local jobSchedulerId = rcall("HGET", jobKey, "rjk")
78
80
  local isRepeatableJob = false
79
- if jobOpts then
80
- local opts = cjson.decode(jobOpts)
81
- if opts and opts["repeat"] then
81
+ if jobSchedulerId then
82
+ local schedulerKey = repeatKey .. ":" .. jobSchedulerId
83
+
84
+ if rcall("EXISTS", schedulerKey) == 1 then
82
85
  isRepeatableJob = true
86
+ else
87
+ -- TODO: remove this check in v6, as it is only needed for legacy repeatable jobs
88
+ -- that stored the scheduler id in the job key but did not create the scheduler hash key
89
+ local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
90
+ if prevMillis then
91
+ isRepeatableJob = true
92
+ end
83
93
  end
84
94
  end
85
95
 
@@ -25,7 +25,7 @@ export * from './isJobInList-1';
25
25
  export * from './isMaxed-2';
26
26
  export * from './moveJobFromActiveToWait-9';
27
27
  export * from './moveJobsToWait-8';
28
- export * from './moveStalledJobsToWait-8';
28
+ export * from './moveStalledJobsToWait-9';
29
29
  export * from './moveToActive-11';
30
30
  export * from './moveToDelayed-12';
31
31
  export * from './moveToFinished-14';
@@ -25,7 +25,7 @@ export * from './isJobInList-1';
25
25
  export * from './isMaxed-2';
26
26
  export * from './moveJobFromActiveToWait-9';
27
27
  export * from './moveJobsToWait-8';
28
- export * from './moveStalledJobsToWait-8';
28
+ export * from './moveStalledJobsToWait-9';
29
29
  export * from './moveToActive-11';
30
30
  export * from './moveToDelayed-12';
31
31
  export * from './moveToFinished-14';
@@ -9,6 +9,7 @@ const content = `--[[
9
9
  KEYS[6] 'paused', (LIST)
10
10
  KEYS[7] 'marker'
11
11
  KEYS[8] 'event stream' (STREAM)
12
+ KEYS[9] 'repeat' key
12
13
  ARGV[1] Max stalled job count
13
14
  ARGV[2] queue.toKey('')
14
15
  ARGV[3] timestamp
@@ -111,6 +112,7 @@ local metaKey = KEYS[5]
111
112
  local pausedKey = KEYS[6]
112
113
  local markerKey = KEYS[7]
113
114
  local eventStreamKey = KEYS[8]
115
+ local repeatKey = KEYS[9]
114
116
  local maxStalledJobCount = tonumber(ARGV[1])
115
117
  local queueKeyPrefix = ARGV[2]
116
118
  local timestamp = ARGV[3]
@@ -142,12 +144,19 @@ if (#stalling > 0) then
142
144
  -- If this job has been stalled too many times, such as if it crashes the worker, then fail it.
143
145
  local stalledCount = rcall("HINCRBY", jobKey, "stc", 1)
144
146
  -- Check if this is a repeatable job by looking at job options
145
- local jobOpts = rcall("HGET", jobKey, "opts")
147
+ local jobSchedulerId = rcall("HGET", jobKey, "rjk")
146
148
  local isRepeatableJob = false
147
- if jobOpts then
148
- local opts = cjson.decode(jobOpts)
149
- if opts and opts["repeat"] then
149
+ if jobSchedulerId then
150
+ local schedulerKey = repeatKey .. ":" .. jobSchedulerId
151
+ if rcall("EXISTS", schedulerKey) == 1 then
150
152
  isRepeatableJob = true
153
+ else
154
+ -- TODO: remove this check in v6, as it is only needed for legacy repeatable jobs
155
+ -- that stored the scheduler id in the job key but did not create the scheduler hash key
156
+ local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
157
+ if prevMillis then
158
+ isRepeatableJob = true
159
+ end
151
160
  end
152
161
  end
153
162
  -- Only fail job if it exceeds stall limit AND is not a repeatable job
@@ -177,5 +186,5 @@ return stalled
177
186
  export const moveStalledJobsToWait = {
178
187
  name: 'moveStalledJobsToWait',
179
188
  content,
180
- keys: 8,
189
+ keys: 9,
181
190
  };