Skip to content

Commit 163d6fb

Browse files
authored
fix concurrent rw hash map (#9008) (#9039)
1 parent d04d9bb commit 163d6fb

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

ydb/core/control/immediate_control_board_impl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bool TControlBoard::RegisterLocalControl(TControlWrapper control, TString name)
1616
}
1717

1818
bool TControlBoard::RegisterSharedControl(TControlWrapper& control, TString name) {
19-
auto& ptr = Board.InsertIfAbsent(name, control.Control);
19+
auto ptr = Board.InsertIfAbsent(name, control.Control);
2020
if (control.Control == ptr) {
2121
return true;
2222
} else {

ydb/core/tablet/private/aggregated_counters.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class TAggregatedHistogramCounters {
140140
TVector<TCountersByTabletIdMap> CountersByTabletId; // each index is map from tablet to counter value
141141
};
142142

143-
class TAggregatedLabeledCounters {
143+
class TAggregatedLabeledCounters : public TThrRefBase {
144144
public:
145145
//
146146
TAggregatedLabeledCounters(ui32 count, const ui8* aggrFunc, const char * const * names, const ui8* types, const TString& groupNames);

ydb/core/tablet/private/labeled_db_counters.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void TPQCounters::Apply(ui64 tabletId, const NKikimr::TTabletLabeledCountersBase
3131
}
3232
}
3333

34-
auto& el = LabeledCountersByGroup.InsertIfAbsent(group, new TAggregatedLabeledCounters(
34+
auto el = LabeledCountersByGroup.InsertIfAbsent(group, new TAggregatedLabeledCounters(
3535
labeledCounters->GetCounters().Size(), labeledCounters->GetAggrFuncs(),
3636
labeledCounters->GetNames(), labeledCounters->GetTypes(), groupNames));
3737

ydb/core/tablet/private/labeled_db_counters.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace NKikimr::NPrivate {
1313

1414
class TPQCounters : public ILabeledCounters {
1515
protected:
16-
TConcurrentRWHashMap<TString, TAutoPtr<TAggregatedLabeledCounters>, 256> LabeledCountersByGroup;
16+
TConcurrentRWHashMap<TString, TIntrusivePtr<TAggregatedLabeledCounters>, 256> LabeledCountersByGroup;
1717
NMonitoring::TDynamicCounterPtr Group;
1818

1919
public:

ydb/core/util/concurrent_rw_hash.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ class TConcurrentRWHashMap {
4949
bucket.Map[key] = value;
5050
}
5151

52-
V& InsertIfAbsent(const K& key, const V& value) {
52+
V InsertIfAbsent(const K& key, const V& value) {
5353
TBucket& bucket = GetBucketForKey(key);
5454
TWriteGuard guard(bucket.RWLock);
5555

5656
return bucket.Map.insert(std::make_pair(key, value)).first->second;
5757
}
5858

5959
template <typename Callable>
60-
V& InsertIfAbsentWithInit(const K& key, Callable initFunc) {
60+
V InsertIfAbsentWithInit(const K& key, Callable initFunc) {
6161
TBucket& bucket = GetBucketForKey(key);
6262
TWriteGuard guard(bucket.RWLock);
6363

0 commit comments

Comments
 (0)