chetanmeh commented on a change in pull request #4326: Invoker backpressure
URL: 
https://github.com/apache/incubator-openwhisk/pull/4326#discussion_r289333718
 
 

 ##########
 File path: 
core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerPool.scala
 ##########
 @@ -227,48 +276,131 @@ class ContainerPool(childFactory: ActorRefFactory => 
ActorRef,
         busyPool = busyPool + (sender() -> newData)
         freePool = freePool - sender()
       }
+      updateUnused() //in case a previously in-use is now unused
+      processBuffer()
 
     // Container is prewarmed and ready to take work
     case NeedWork(data: PreWarmedData) =>
+      //stop tracking via reserved
+      resourceManager.releaseReservation(sender())
       prewarmedPool = prewarmedPool + (sender() -> data)
 
     // Container got removed
     case ContainerRemoved =>
+      //stop tracking via reserved (should already be removed, except in case 
of failure)
+      resourceManager.releaseReservation(sender())
+
       // if container was in free pool, it may have been processing (but under 
capacity),
       // so there is capacity to accept another job request
-      freePool.get(sender()).foreach { f =>
+      val foundFree: Option[ActorRef] = freePool.get(sender()).map { f =>
         freePool = freePool - sender()
         if (f.activeActivationCount > 0) {
-          feed ! MessageFeed.Processed
+          processBuffer()
         }
+        updateUnused()
+        sender()
       }
       // container was busy (busy indicates at full capacity), so there is 
capacity to accept another job request
-      busyPool.get(sender()).foreach { _ =>
+      val foundBusy = busyPool.get(sender()).map { _ =>
         busyPool = busyPool - sender()
-        feed ! MessageFeed.Processed
+        processBuffer()
+        sender()
+      }
+      //if container was neither free or busy,
+      if (foundFree.orElse(foundBusy).isEmpty) {
 
 Review comment:
   Is this a defensive handling? From what I understand per pool logic any 
`Container` should always be in one of `busyPool` and `freePool`. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to