@@ -68,6 +68,7 @@ local rcall = redis.call
68
68
--- @include "includes/removeJobKeys"
69
69
--- @include "includes/removeJobsByMaxAge"
70
70
--- @include "includes/removeJobsByMaxCount"
71
+ --- @include "includes/removeLock"
71
72
--- @include "includes/removeParentDependencyKey"
72
73
--- @include "includes/trimEvents"
73
74
--- @include "includes/updateParentDepsIfNeeded"
@@ -77,28 +78,17 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
77
78
local opts = cmsgpack .unpack (ARGV [8 ])
78
79
79
80
local token = opts [' token' ]
81
+
82
+ local errorCode = removeLock (jobIdKey , KEYS [5 ], token , ARGV [1 ])
83
+ if errorCode < 0 then
84
+ return errorCode
85
+ end
86
+
80
87
local attempts = opts [' attempts' ]
81
88
local maxMetricsSize = opts [' maxMetricsSize' ]
82
89
local maxCount = opts [' keepJobs' ][' count' ]
83
90
local maxAge = opts [' keepJobs' ][' age' ]
84
91
85
- if token ~= " 0" then
86
- local lockKey = jobIdKey .. ' :lock'
87
- local lockToken = rcall (" GET" , lockKey )
88
- if lockToken == token then
89
- rcall (" DEL" , lockKey )
90
- rcall (" SREM" , KEYS [5 ], ARGV [1 ])
91
- else
92
- if lockToken then
93
- -- Lock exists but token does not match
94
- return - 6
95
- else
96
- -- Lock is missing completely
97
- return - 2
98
- end
99
- end
100
- end
101
-
102
92
if rcall (" SCARD" , jobIdKey .. " :dependencies" ) ~= 0 then -- // Make sure it does not have pending dependencies
103
93
return - 4
104
94
end
0 commit comments