Commit 6b5e1c2
fix(job): guard processQueue job claim with status=pending and affected-row check (#2899)
* fix(job): guard processQueue job claim with status=pending and affected-row check
processQueue's $processJob marked a job as processing with an unguarded
UPDATE (WHERE id = :id only), so two concurrent workers could both claim
and execute the same job. Mirror JobWorker.cfc::$claimJob: add
AND status = 'pending' to the claim UPDATE and check the affected-row
count via the queryExecute result option on the same statement (a
separate verification SELECT breaks on BoxLang + PostgreSQL when the
pool hands out a different connection).
A lost claim now returns {skipped = true} from $processJob, and
processQueue counts it under a new additive 'skipped' key instead of
recording a failure. attempts increments only on a successful claim,
keeping increment-and-claim atomic.
Spec: new "Job Claim Guard" describe in JobQueueSpec proves an
already-processing row is not re-executed (status stays 'processing',
attempts stays 0), plus a 'skipped' key assertion on the processQueue
result shape. Verified red (22 pass / 2 fail pre-fix) then green
(24 pass / 0 fail) on Lucee 7 + SQLite.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>
* fix(job): address Reviewer A/B consensus findings (round 1)
- vendor/wheels/Job.cfc:238 — drop the redundant StructKeyExists guard
on local.jobResult.skipped. $processJob initialises
local.result = {success = false, skipped = false, error = ""}
unconditionally and every return path returns that struct, so the
key is always present.
- vendor/wheels/tests/specs/jobs/JobQueueSpec.cfc — move the
"Job Claim Guard" describe block's DELETE cleanup from inline at
the end of the it block into afterEach (try/catch-wrapped, matching
beforeEach), so a throw before the inline DELETE no longer leaks
the seeded row. beforeEach still cleans up too (defense in depth).
- CHANGELOG.md — add the [Unreleased] block (Keep a Changelog
convention) with a ### Fixed entry for the processQueue claim guard.
Last [Unreleased] was promoted to 4.0.3 in 08dd480 on 2026-06-09,
so this PR is the first change targeting the 4.0.4 snapshot.
Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
---------
Signed-off-by: Peter Amiri <peter@alurium.com>
Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>1 parent a391bf4 commit 6b5e1c2
3 files changed
Lines changed: 84 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
23 | 27 | | |
24 | 28 | | |
25 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
238 | 243 | | |
239 | 244 | | |
240 | 245 | | |
| |||
250 | 255 | | |
251 | 256 | | |
252 | 257 | | |
253 | | - | |
254 | | - | |
255 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
256 | 266 | | |
257 | 267 | | |
258 | 268 | | |
259 | 269 | | |
260 | | - | |
| 270 | + | |
261 | 271 | | |
262 | 272 | | |
263 | 273 | | |
264 | 274 | | |
265 | | - | |
| 275 | + | |
266 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
267 | 282 | | |
268 | 283 | | |
269 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| |||
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
170 | 229 | | |
171 | 230 | | |
172 | 231 | | |
| |||
0 commit comments