good morning!!!!

Skip to content
Snippets Groups Projects
Commit 56c00bac authored by Garet Halliday's avatar Garet Halliday
Browse files

fix backoff

parent fc889d24
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,6 @@ package pool
import (
"errors"
"sync"
"sync/atomic"
"time"
"github.com/google/uuid"
......@@ -25,8 +24,6 @@ type Pool struct {
closed chan struct{}
isRetrying atomic.Bool
recipes map[string]*recipe.Recipe
clients map[uuid.UUID]*Client
clientsByKey map[[8]byte]*Client
......@@ -147,15 +144,15 @@ func (T *Pool) removeRecipe(name string) {
}
func (T *Pool) scaleUp() {
if T.isRetrying.Load() {
// there is another goroutine trying to retry
return
}
backoff := T.options.ServerReconnectInitialTime
retrying := false
for {
select {
case <-T.closed:
return
default:
}
name, r := func() (string, *recipe.Recipe) {
T.mu.RLock()
defer T.mu.RUnlock()
......@@ -176,9 +173,6 @@ func (T *Pool) scaleUp() {
if r != nil {
err := T.scaleUpL1(name, r)
if err == nil {
if retrying {
T.isRetrying.Store(false)
}
return
}
......@@ -187,20 +181,9 @@ func (T *Pool) scaleUp() {
if backoff == 0 {
// no backoff
if retrying {
T.isRetrying.Store(false)
}
return
}
if !retrying {
if T.isRetrying.Swap(true) {
// another goroutine beat us
return
}
retrying = true
}
time.Sleep(backoff)
backoff *= 2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment