This is an automated email from the ASF dual-hosted git repository.
aloyszhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 9247e428b4 [INLONG-11661][SDK] Do not mark endpoint unavailable when
it is the only one in Golang SDK (#11665)
9247e428b4 is described below
commit 9247e428b42fcd8a7d9a770ac55ef1869ab59c8f
Author: gunli <[email protected]>
AuthorDate: Wed Jan 15 11:04:31 2025 +0800
[INLONG-11661][SDK] Do not mark endpoint unavailable when it is the only
one in Golang SDK (#11665)
---
.../dataproxy-sdk-golang/connpool/connpool.go | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git
a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/connpool/connpool.go
b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/connpool/connpool.go
index d8f3a1a3ba..d3bee80d0c 100755
--- a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/connpool/connpool.go
+++ b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/connpool/connpool.go
@@ -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)
@@ -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 {