Skip to content

Commit

Permalink
Merge pull request #1628 from ydb-platform/blackduck
Browse files Browse the repository at this point in the history
Blackduck
  • Loading branch information
rekby authored Jan 31, 2025
2 parents e241a4d + d8c9964 commit 67aec4b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* Fixed potential infinity loop for local dc detection
* Fixed nil pointer dereferenced in a topic listener

## v3.99.2
* Fixed panic when error returned from parsing sql params
* Fixed explicit null dereferenced issue in internal/credentials/static.go (CWE-476)
Expand Down
20 changes: 6 additions & 14 deletions internal/balancer/local_dc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math/rand"
"net"
"net/url"
"slices"
"strings"
"sync"

Expand Down Expand Up @@ -157,21 +158,12 @@ func getRandomEndpoints(endpoints []endpoint.Endpoint, count int) []endpoint.End
return endpoints
}

got := make(map[int]bool, maxEndpointsCheckPerLocation)
endpoints = slices.Clone(endpoints)
rand.Shuffle(len(endpoints), func(i, j int) {
endpoints[i], endpoints[j] = endpoints[j], endpoints[i]
})

res := make([]endpoint.Endpoint, 0, maxEndpointsCheckPerLocation)
for len(got) < count {
//nolint:gosec
index := rand.Intn(len(endpoints))
if got[index] {
continue
}

got[index] = true
res = append(res, endpoints[index])
}

return res
return endpoints[:count]
}

func splitEndpointsByLocation(endpoints []endpoint.Endpoint) map[string][]endpoint.Endpoint {
Expand Down
5 changes: 0 additions & 5 deletions internal/topic/topiclistenerinternal/stream_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,6 @@ func (l *streamListener) onStopPartitionRequest(
m *rawtopicreader.StopPartitionSessionRequest,
) error {
session, err := l.sessions.Get(m.PartitionSessionID)
if !m.Graceful && session == nil {
// stop partition may be received twice: graceful and force
// the sdk we can forget about the session after graceful stop
return nil
}
if err != nil {
return err
}
Expand Down

0 comments on commit 67aec4b

Please sign in to comment.