From 8115c6325fe78185f86e819f2fc228708c7764b8 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Tue, 30 Nov 2021 15:05:48 +0300 Subject: update vector, add more comments, remove redundand worker kill Signed-off-by: Valery Piashchynski --- worker_watcher/container/channel/vec.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/worker_watcher/container/channel/vec.go b/worker_watcher/container/channel/vec.go index 958a217c..c0c27575 100644 --- a/worker_watcher/container/channel/vec.go +++ b/worker_watcher/container/channel/vec.go @@ -44,9 +44,12 @@ func (v *Vec) Push(w worker.BaseProcess) { 1. TTL is set with no requests during the TTL 2. Violated Get <-> Release operation (how ??) */ + for i := 0; i < len(v.workers); i++ { /* We need to drain vector until we found a worker in the Invalid/Killing/Killed/etc states. + BUT while we are draining the vector, some worker might be reallocated and pushed into the v.workers + so, down by the code, we might have a problem when pushing the new worker to the v.workers */ wrk := <-v.workers @@ -60,13 +63,10 @@ func (v *Vec) Push(w worker.BaseProcess) { case v.workers <- wrk: continue default: - // kill the new worker and reallocate it - w.State().Set(worker.StateInvalid) - _ = w.Kill() - // kill the worker from the channel wrk.State().Set(worker.StateInvalid) _ = wrk.Kill() + continue } /* -- cgit v1.2.3