Skip to content

Commit 67aec4b

Browse files
authored
Merge pull request #1628 from ydb-platform/blackduck
Blackduck
2 parents e241a4d + d8c9964 commit 67aec4b

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* Fixed potential infinity loop for local dc detection
2+
* Fixed nil pointer dereferenced in a topic listener
3+
14
## v3.99.2
25
* Fixed panic when error returned from parsing sql params
36
* Fixed explicit null dereferenced issue in internal/credentials/static.go (CWE-476)

internal/balancer/local_dc.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"math/rand"
88
"net"
99
"net/url"
10+
"slices"
1011
"strings"
1112
"sync"
1213

@@ -157,21 +158,12 @@ func getRandomEndpoints(endpoints []endpoint.Endpoint, count int) []endpoint.End
157158
return endpoints
158159
}
159160

160-
got := make(map[int]bool, maxEndpointsCheckPerLocation)
161+
endpoints = slices.Clone(endpoints)
162+
rand.Shuffle(len(endpoints), func(i, j int) {
163+
endpoints[i], endpoints[j] = endpoints[j], endpoints[i]
164+
})
161165

162-
res := make([]endpoint.Endpoint, 0, maxEndpointsCheckPerLocation)
163-
for len(got) < count {
164-
//nolint:gosec
165-
index := rand.Intn(len(endpoints))
166-
if got[index] {
167-
continue
168-
}
169-
170-
got[index] = true
171-
res = append(res, endpoints[index])
172-
}
173-
174-
return res
166+
return endpoints[:count]
175167
}
176168

177169
func splitEndpointsByLocation(endpoints []endpoint.Endpoint) map[string][]endpoint.Endpoint {

internal/topic/topiclistenerinternal/stream_listener.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,6 @@ func (l *streamListener) onStopPartitionRequest(
339339
m *rawtopicreader.StopPartitionSessionRequest,
340340
) error {
341341
session, err := l.sessions.Get(m.PartitionSessionID)
342-
if !m.Graceful && session == nil {
343-
// stop partition may be received twice: graceful and force
344-
// the sdk we can forget about the session after graceful stop
345-
return nil
346-
}
347342
if err != nil {
348343
return err
349344
}

0 commit comments

Comments
 (0)