@@ -304,9 +304,9 @@ internal class OperationRepo(
304
304
}
305
305
}
306
306
307
- // set post create delay if the execution resulted in ID translations to stall processing
308
- val postCreateDelay = response.idTranslations?. let { _configModelStore .model.opRepoPostCreateDelay } ? : 0
309
- delayBeforeNextExecution(highestRetries, response.retryAfterSeconds, postCreateDelay )
307
+ // wait for retry and post create waiters to start next operation
308
+ delayBeforeNextExecution(highestRetries, response.retryAfterSeconds)
309
+ delayForPostCreate( response.idTranslations != null )
310
310
} catch (e: Throwable ) {
311
311
Logging .log(LogLevel .ERROR , " Error attempting to execute operation: $ops " , e)
312
312
@@ -317,39 +317,43 @@ internal class OperationRepo(
317
317
}
318
318
319
319
/* *
320
- * Wait which ever is longer, post create delay, retryAfterSeconds returned by the server,
320
+ * Wait which ever is longer, retryAfterSeconds returned by the server,
321
321
* or based on the retry count.
322
- *
323
- * postCreateDelay: Stall processing the queue so the backend's DB has to time reflect the
324
- * change before we do any other operations to it.
325
- *
326
- * NOTE: Future: We could run this logic in a
327
- * coroutineScope.launch() block so other operations not
328
- * effecting this these id's can still be done in parallel,
329
- * however other parts of the system don't currently account
330
- * for this so this is not safe to do.
331
322
*/
332
323
suspend fun delayBeforeNextExecution (
333
324
retries : Int ,
334
325
retryAfterSeconds : Int? ,
335
- postCreateDelay : Long ,
336
326
) {
337
327
Logging .debug(" retryAfterSeconds: $retryAfterSeconds " )
338
328
val retryAfterSecondsNonNull = retryAfterSeconds?.toLong() ? : 0L
339
329
val delayForOnRetries = retries * _configModelStore .model.opRepoDefaultFailRetryBackoff
340
- val delayFor = max(delayForOnRetries, max( retryAfterSecondsNonNull * 1_000 , postCreateDelay) )
330
+ val delayFor = max(delayForOnRetries, retryAfterSecondsNonNull * 1_000 )
341
331
if (delayFor < 1 ) return
342
- // do not log error if there is an expected delay for post create
343
- if (delayFor == postCreateDelay) {
344
- Logging .debug(" Operations being delay for $delayFor ms due to PostCreateDelay" )
345
- } else {
346
- Logging .error(" Operations being delay for: $delayFor ms" )
347
- }
332
+ Logging .error(" Operations being delay for: $delayFor ms" )
348
333
withTimeoutOrNull(delayFor) {
349
334
retryWaiter.waitForWake()
350
335
}
351
336
}
352
337
338
+ /* *
339
+ * Stall processing the queue so the backend's DB has to time
340
+ * reflect the change before we do any other operations to it.
341
+ * NOTE: Future: We could run this logic in a
342
+ * coroutineScope.launch() block so other operations not
343
+ * effecting this these id's can still be done in parallel,
344
+ * however other parts of the system don't currently account
345
+ * for this so this is not safe to do.
346
+ */
347
+ suspend fun delayForPostCreate (hasIDTranslation : Boolean ) {
348
+ val postCreateDelay: Long = _configModelStore .model.opRepoPostCreateDelay
349
+ if (! hasIDTranslation || postCreateDelay == 0L )
350
+ return
351
+ delay(postCreateDelay)
352
+ synchronized(queue) {
353
+ if (queue.isNotEmpty()) waiter.wake(LoopWaiterMessage (false , postCreateDelay))
354
+ }
355
+ }
356
+
353
357
internal fun getNextOps (bucketFilter : Int ): List <OperationQueueItem >? {
354
358
return synchronized(queue) {
355
359
val startingOp =
0 commit comments