Commit 9b95e6b
fix(worker): Cap bundle analysis processor at 10 attempts and fix retry logic (#688)
* fix(worker): Cap bundle analysis processor at 10 attempts and fix retry logic
Cap total attempts at 10 (not 10 retries + 1) for BundleAnalysisProcessorTask
and LockManager so we stop after 10 tries. Add Redis-backed attempt counter
in LockManager for lock contention so broker re-deliveries with unchanged
headers do not retry indefinitely. BaseCodecovTask._has_exceeded_max_attempts
now takes max_attempts and compares to attempts (retries + 1 or header).
On generic exception in bundle processor, return and set upload to error
instead of re-raising to avoid unbounded retries. Update tests: mock request
for _has_exceeded_max_attempts, set mock_redis.incr.return_value where
LockManager compares attempts, and adjust cleanup test to expect return
instead of raised ValueError.
Refs CCMRG-2042
Co-authored-by: Cursor <cursoragent@cursor.com>
* ref(worker): Extract lock clear helper, fix finisher log, clean comments
- LockManager: extract _clear_lock_attempt_counter to remove nested try in locked()
- Upload finisher: log max_attempts as UPLOAD_PROCESSOR_MAX_RETRIES (not +1)
- Lock_manager: comment TTL intent instead of restating 24h
- Tests: remove hard-coded (10) from comments; use max_attempts wording
Co-authored-by: Cursor <cursoragent@cursor.com>
* ref(worker): use max_retries only, remove max_attempts alias
- BaseCodecovTask: doc and safe_retry use max_retries; drop max_attempts property
- LockRetry: max_attempts -> max_retries (same semantics: max total attempts)
- LockManager/bundle_analysis_processor/upload_finisher: log and Sentry use max_retries
- Tests: LockRetry(max_retries=...), comments say max_retries
- celery_config: one-line convention (max_retries = max total attempts)
- Fix duplicate dict keys in lock_manager and upload_finisher
Refs CCMRG-2042
Co-authored-by: Cursor <cursoragent@cursor.com>
* test(worker): set mock_redis.incr.return_value in BA retry countdown test
LockManager uses redis incr for attempt count; mock must return an int
so attempts >= max_retries does not raise TypeError.
Refs CCMRG-2042
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(worker): honor LockRetry.max_retries_exceeded in ManualTriggerTask
When LockManager's Redis attempt counter hits max_retries before the task's
attempt count (e.g. re-deliveries), it raises LockRetry(max_retries_exceeded=True,
countdown=0). ManualTriggerTask only checked self._has_exceeded_max_attempts(),
so it fell through to self.retry(countdown=0) and caused rapid zero-delay retries.
Align with preprocess_upload and other callers: check retry.max_retries_exceeded
or self._has_exceeded_max_attempts() and return failure dict when either is true.
Add test for the Redis-counter path.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(worker): Address PR feedback for bundle analysis and lock manager
- Return processing_results in max-retries-exceeded path for consistent
defensive isinstance behavior (bundle_analysis_processor)
- Consolidate redis exception imports; add blank line between lock_name
and attempt_key in LockManager.locked() (lock_manager)
Refs CCMRG-2042
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 10c6c66 commit 9b95e6b
File tree
16 files changed
+284
-184
lines changed- apps/worker
- services
- tests
- tasks
- tests
- integration
- unit
16 files changed
+284
-184
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
47 | | - | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
54 | 60 | | |
55 | | - | |
| 61 | + | |
56 | 62 | | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
61 | | - | |
| 67 | + | |
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
| |||
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
96 | 118 | | |
97 | 119 | | |
98 | 120 | | |
| |||
106 | 128 | | |
107 | 129 | | |
108 | 130 | | |
109 | | - | |
| 131 | + | |
110 | 132 | | |
111 | 133 | | |
| 134 | + | |
| 135 | + | |
112 | 136 | | |
113 | 137 | | |
114 | 138 | | |
| |||
134 | 158 | | |
135 | 159 | | |
136 | 160 | | |
137 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
138 | 165 | | |
139 | 166 | | |
140 | 167 | | |
| |||
147 | 174 | | |
148 | 175 | | |
149 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
150 | 183 | | |
151 | 184 | | |
152 | 185 | | |
| |||
159 | 192 | | |
160 | 193 | | |
161 | 194 | | |
162 | | - | |
163 | | - | |
| 195 | + | |
164 | 196 | | |
165 | 197 | | |
166 | 198 | | |
167 | | - | |
168 | | - | |
| 199 | + | |
| 200 | + | |
169 | 201 | | |
170 | 202 | | |
171 | 203 | | |
172 | 204 | | |
173 | 205 | | |
174 | | - | |
| 206 | + | |
175 | 207 | | |
| 208 | + | |
176 | 209 | | |
177 | 210 | | |
178 | 211 | | |
179 | | - | |
180 | 212 | | |
181 | 213 | | |
182 | 214 | | |
183 | | - | |
184 | 215 | | |
185 | 216 | | |
186 | 217 | | |
187 | 218 | | |
188 | 219 | | |
189 | 220 | | |
190 | 221 | | |
| 222 | + | |
191 | 223 | | |
192 | 224 | | |
193 | 225 | | |
194 | 226 | | |
195 | 227 | | |
196 | | - | |
| 228 | + | |
197 | 229 | | |
198 | 230 | | |
199 | | - | |
200 | 231 | | |
201 | 232 | | |
202 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
| |||
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
| 161 | + | |
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
| |||
169 | 171 | | |
170 | 172 | | |
171 | 173 | | |
| 174 | + | |
172 | 175 | | |
173 | 176 | | |
174 | 177 | | |
| |||
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
| 187 | + | |
184 | 188 | | |
185 | 189 | | |
186 | 190 | | |
| |||
193 | 197 | | |
194 | 198 | | |
195 | 199 | | |
| 200 | + | |
196 | 201 | | |
197 | 202 | | |
198 | 203 | | |
| |||
206 | 211 | | |
207 | 212 | | |
208 | 213 | | |
| 214 | + | |
209 | 215 | | |
210 | 216 | | |
211 | 217 | | |
| |||
219 | 225 | | |
220 | 226 | | |
221 | 227 | | |
| 228 | + | |
222 | 229 | | |
223 | 230 | | |
224 | 231 | | |
| |||
234 | 241 | | |
235 | 242 | | |
236 | 243 | | |
237 | | - | |
| 244 | + | |
238 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
239 | 249 | | |
240 | 250 | | |
241 | 251 | | |
242 | 252 | | |
243 | 253 | | |
244 | 254 | | |
245 | 255 | | |
246 | | - | |
247 | 256 | | |
248 | 257 | | |
249 | | - | |
250 | | - | |
| 258 | + | |
| 259 | + | |
251 | 260 | | |
252 | 261 | | |
253 | 262 | | |
| |||
256 | 265 | | |
257 | 266 | | |
258 | 267 | | |
259 | | - | |
| 268 | + | |
260 | 269 | | |
261 | 270 | | |
262 | 271 | | |
263 | | - | |
| 272 | + | |
264 | 273 | | |
265 | 274 | | |
266 | | - | |
| 275 | + | |
267 | 276 | | |
| 277 | + | |
268 | 278 | | |
269 | 279 | | |
270 | 280 | | |
271 | 281 | | |
272 | | - | |
273 | | - | |
274 | 282 | | |
275 | 283 | | |
276 | 284 | | |
277 | | - | |
278 | 285 | | |
279 | 286 | | |
280 | | - | |
281 | | - | |
| 287 | + | |
| 288 | + | |
282 | 289 | | |
283 | 290 | | |
284 | 291 | | |
285 | 292 | | |
286 | 293 | | |
287 | | - | |
| 294 | + | |
288 | 295 | | |
289 | 296 | | |
290 | 297 | | |
291 | 298 | | |
292 | 299 | | |
293 | 300 | | |
| 301 | + | |
294 | 302 | | |
295 | 303 | | |
296 | 304 | | |
| |||
358 | 366 | | |
359 | 367 | | |
360 | 368 | | |
| 369 | + | |
361 | 370 | | |
362 | 371 | | |
363 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
185 | 191 | | |
186 | 192 | | |
187 | 193 | | |
| |||
306 | 312 | | |
307 | 313 | | |
308 | 314 | | |
309 | | - | |
| 315 | + | |
310 | 316 | | |
311 | 317 | | |
312 | 318 | | |
313 | | - | |
314 | | - | |
| 319 | + | |
315 | 320 | | |
316 | 321 | | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
| 322 | + | |
322 | 323 | | |
323 | | - | |
324 | | - | |
325 | 324 | | |
326 | 325 | | |
327 | 326 | | |
328 | 327 | | |
329 | | - | |
330 | 328 | | |
331 | 329 | | |
332 | 330 | | |
333 | 331 | | |
334 | 332 | | |
335 | 333 | | |
336 | 334 | | |
337 | | - | |
| 335 | + | |
338 | 336 | | |
339 | 337 | | |
340 | 338 | | |
341 | 339 | | |
342 | | - | |
343 | 340 | | |
344 | 341 | | |
345 | 342 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
0 commit comments