diff options
Diffstat (limited to 'worker_watcher/container/channel/vec.go')
-rw-r--r-- | worker_watcher/container/channel/vec.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/worker_watcher/container/channel/vec.go b/worker_watcher/container/channel/vec.go index fd50c8d1..63df052f 100644 --- a/worker_watcher/container/channel/vec.go +++ b/worker_watcher/container/channel/vec.go @@ -69,8 +69,16 @@ func (v *Vec) Push(w worker.BaseProcess) { // replace with the new one and return from the loop // new worker can be ttl-ed at this moment, it's possible to replace TTL-ed worker with new TTL-ed worker // But this case will be handled in the worker_watcher::Get - v.workers <- w - return + select { + case v.workers <- w: + return + // the place for the new worker was occupied before + default: + // kill the new worker and reallocate it + w.State().Set(worker.StateInvalid) + _ = w.Kill() + return + } } } } |