Skip to content

Commit

Permalink
Merge pull request #1468 from ydb-platform/fix-cincurrent-map-writes
Browse files Browse the repository at this point in the history
Fix concurrent map writes in metrics
  • Loading branch information
neyguvj authored Sep 17, 2024
2 parents e582517 + 4f959f2 commit 66ffc00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Fixed concurrent map writes in metrics
* Renamed method at experimental API reader.PopBatchTx to reader.PopMessagesBatchTx

## v3.80.5
Expand Down
4 changes: 4 additions & 0 deletions metrics/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package metrics

import (
"strconv"
"sync"

"github.com/ydb-platform/ydb-go-sdk/v3/internal/repeater"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
Expand All @@ -26,6 +27,7 @@ func driver(config Config) (t trace.Driver) {
az string
}
knownEndpoints := make(map[endpointKey]struct{})
endpointsMu := sync.RWMutex{}

t.OnConnInvoke = func(info trace.DriverConnInvokeStartInfo) func(trace.DriverConnInvokeDoneInfo) {
var (
Expand Down Expand Up @@ -104,6 +106,8 @@ func driver(config Config) (t trace.Driver) {

return func(info trace.DriverBalancerUpdateDoneInfo) {
if config.Details()&trace.DriverBalancerEvents != 0 {
endpointsMu.Lock()
defer endpointsMu.Unlock()
balancerUpdates.With(map[string]string{
"cause": eventType,
}).Inc()
Expand Down

0 comments on commit 66ffc00

Please sign in to comment.