Commit 886ee8f
committed
[IMP] queue_job: refactor job acquisition
In this commit we cleanly separate the job acquisition (i.e. verifying the job is in the exepected state, marking it started and locking it) from job execution.
We also avoid trying to start the job if it is already locked by using SKIP LOCKED
and exiting early. Indeed in such situations the job is likely already being handled by another worker so there is no point trying to start it, so we exit early
and let it be handled either by the other worker or the dead job requeuer.1 parent 6792545 commit 886ee8f
2 files changed
+45
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
32 | 57 | | |
33 | 58 | | |
34 | 59 | | |
35 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
36 | 67 | | |
| 68 | + | |
| 69 | + | |
37 | 70 | | |
38 | | - | |
39 | 71 | | |
40 | 72 | | |
41 | 73 | | |
| |||
94 | 126 | | |
95 | 127 | | |
96 | 128 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 129 | + | |
| 130 | + | |
109 | 131 | | |
110 | 132 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | 133 | | |
115 | 134 | | |
116 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
245 | | - | |
246 | | - | |
| 244 | + | |
| 245 | + | |
247 | 246 | | |
248 | | - | |
249 | | - | |
250 | | - | |
| 247 | + | |
| 248 | + | |
251 | 249 | | |
252 | 250 | | |
253 | 251 | | |
| |||
265 | 263 | | |
266 | 264 | | |
267 | 265 | | |
268 | | - | |
| 266 | + | |
269 | 267 | | |
270 | 268 | | |
271 | 269 | | |
272 | 270 | | |
273 | 271 | | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 272 | + | |
278 | 273 | | |
279 | 274 | | |
280 | 275 | | |
| |||
0 commit comments