@@ -75,6 +75,7 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
75
75
var busyPool = immutable.Map .empty[ActorRef , ContainerData ]
76
76
var prewarmedPool = immutable.Map .empty[ActorRef , ContainerData ]
77
77
var prewarmStartingPool = immutable.Map .empty[ActorRef , (String , ByteSize )]
78
+ var latestPrewarmConfig = prewarmConfig
78
79
// If all memory slots are occupied and if there is currently no container to be removed, than the actions will be
79
80
// buffered here to keep order of computation.
80
81
// Otherwise actions with small memory-limits could block actions with large memory limits.
@@ -285,14 +286,20 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
285
286
freePool = freePool - sender()
286
287
busyPool = busyPool - sender()
287
288
case prewarmConfigList : PreWarmConfigList =>
288
- // Delete prewarmedPool firstly
289
- prewarmedPool foreach { element =>
290
- val actor = element._1
291
- actor ! Remove
292
- prewarmedPool = prewarmedPool - actor
293
- }
289
+ latestPrewarmConfig = prewarmConfigList.list
294
290
prewarmConfigList.list foreach { config =>
295
- logging.info(this , s " add extra pre-warming ${config.count} ${config.exec.kind} ${config.memoryLimit.toString}" )(
291
+ // Delete matched prewarm container from prewarmedPool firstly
292
+ val kind = config.exec.kind
293
+ val memory = config.memoryLimit
294
+ prewarmedPool.filter {
295
+ case (_, PreWarmedData (_, `kind`, `memory`, _)) => true
296
+ case _ => false
297
+ } foreach { element =>
298
+ val actor = element._1
299
+ actor ! Remove
300
+ prewarmedPool = prewarmedPool - actor
301
+ }
302
+ logging.info(this , s " add pre-warming ${config.count} ${config.exec.kind} ${config.memoryLimit.toString}" )(
296
303
TransactionId .invokerWarmup)
297
304
(1 to config.count).foreach { _ =>
298
305
prewarmContainer(config.exec, config.memoryLimit)
@@ -325,7 +332,7 @@ class ContainerPool(childFactory: ActorRefFactory => ActorRef,
325
332
326
333
/** Install prewarm containers up to the configured requirements for each kind/memory combination. */
327
334
def backfillPrewarms (init : Boolean ) = {
328
- prewarmConfig .foreach { config =>
335
+ latestPrewarmConfig .foreach { config =>
329
336
val kind = config.exec.kind
330
337
val memory = config.memoryLimit
331
338
val currentCount = prewarmedPool.count {
0 commit comments