@@ -154,13 +154,18 @@ class WorkerCommand : CliCommand {
154
154
try {
155
155
infraManager.load(infraId, null , diagnosticRecorder)
156
156
} catch (e: OSRDError ) {
157
- if (e.osrdErrorType == ErrorType .InfraHardLoadingError ) {
158
- logger.warn(" Failed to load infra $infraId with a perennial error: $e " )
159
- // go on and future requests will be consumed and rejected
160
- } else if (e.osrdErrorType == ErrorType .InfraSoftLoadingError ) {
161
- logger.error(" Failed to load infra $infraId with a temporary error: $e " )
162
- // Stop worker and let another worker spawn eventually
163
- throw e
157
+ val isInfraLoadError =
158
+ setOf (ErrorType .InfraHardLoadingError , ErrorType .InfraSoftLoadingError )
159
+ .contains(e.osrdErrorType)
160
+ if (isInfraLoadError) {
161
+ if (e.osrdErrorType.isRecoverable) {
162
+ logger.warn(" Failed to load infra $infraId with a perennial error: $e " )
163
+ // go on and future requests will be consumed and rejected
164
+ } else {
165
+ logger.error(" Failed to load infra $infraId with a temporary error: $e " )
166
+ // Stop worker and let another worker spawn eventually
167
+ throw e
168
+ }
164
169
} else {
165
170
logger.error(
166
171
" Failed to load infra $infraId with an unexpected OSRD Error: $e "
@@ -268,7 +273,7 @@ class WorkerCommand : CliCommand {
268
273
.toByteArray() // TODO: have a valid payload for uncaught exceptions
269
274
status = " core_error" .encodeToByteArray()
270
275
// Stop worker and let another worker spawn eventually
271
- if (t is OSRDError && t.osrdErrorType == ErrorType . InfraSoftLoadingError ) {
276
+ if (t is OSRDError && ! t.osrdErrorType.isRecoverable ) {
272
277
throw t
273
278
}
274
279
} finally {
@@ -308,7 +313,7 @@ class WorkerCommand : CliCommand {
308
313
WORKER_REQUESTS_QUEUE ,
309
314
false ,
310
315
mapOf (),
311
- DeliverCallback { _, message ->
316
+ { _, message ->
312
317
if (executor.queue.count() >= WORKER_THREADS * 4 ) {
313
318
// We directly process the message with no dispatch if there's too many
314
319
// locally queued tasks. Prevents the worker from consuming all the rabbitmq
@@ -327,13 +332,13 @@ class WorkerCommand : CliCommand {
327
332
}
328
333
)
329
334
330
- logger.info(" consume ended" )
331
-
332
335
while (true ) {
333
336
Thread .sleep(100 )
334
337
if (! channel.isOpen()) break
335
338
}
336
339
340
+ logger.info(" consume ended" )
341
+
337
342
return 0
338
343
}
339
344
}
0 commit comments