Skip to content

Commit

Permalink
[INLONG-11661][SDK] Do not mark endpoint unavailable when it is the o…
Browse files Browse the repository at this point in the history
…nly one in Golang SDK (#11665)
  • Loading branch information
gunli authored Jan 15, 2025
1 parent 9030cf3 commit 9247e42
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,13 @@ loop:
}

func (p *connPool) markUnavailable(ep string) {
// if there is only 1 endpoint, it is always available
// it is common when endpoint address is a CLB VIP
epCount := p.getEndpointCount()
if epCount <= 1 {
return
}

p.log.Debug("endpoint cannot be connected, marking as unavailable, addr: ", ep)
p.unavailable.Store(ep, time.Now())
p.retryCounts.Store(ep, 0)
Expand Down Expand Up @@ -567,6 +574,16 @@ func (p *connPool) getConnCount() int {
return totalConnCount
}

func (p *connPool) getEndpointCount() int {
epValue := p.endpoints.Load()
endpoints, ok := epValue.([]string)
if !ok {
return 0
}

return len(endpoints)
}

func (p *connPool) getAvailableEndpointCount() int {
unavailableEndpointNum := 0
p.unavailable.Range(func(key, value any) bool {
Expand Down

0 comments on commit 9247e42

Please sign in to comment.