Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix concurrent rw hash map (#9008) #9041

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ydb/core/control/immediate_control_board_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool TControlBoard::RegisterLocalControl(TControlWrapper control, TString name)
}

bool TControlBoard::RegisterSharedControl(TControlWrapper& control, TString name) {
auto& ptr = Board.InsertIfAbsent(name, control.Control);
auto ptr = Board.InsertIfAbsent(name, control.Control);
if (control.Control == ptr) {
return true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet/private/aggregated_counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class TAggregatedHistogramCounters {
TVector<TCountersByTabletIdMap> CountersByTabletId; // each index is map from tablet to counter value
};

class TAggregatedLabeledCounters {
class TAggregatedLabeledCounters : public TThrRefBase {
public:
//
TAggregatedLabeledCounters(ui32 count, const ui8* aggrFunc, const char * const * names, const ui8* types, const TString& groupNames);
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet/private/labeled_db_counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void TPQCounters::Apply(ui64 tabletId, const NKikimr::TTabletLabeledCountersBase
}
}

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

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet/private/labeled_db_counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace NKikimr::NPrivate {

class TPQCounters : public ILabeledCounters {
protected:
TConcurrentRWHashMap<TString, TAutoPtr<TAggregatedLabeledCounters>, 256> LabeledCountersByGroup;
TConcurrentRWHashMap<TString, TIntrusivePtr<TAggregatedLabeledCounters>, 256> LabeledCountersByGroup;
NMonitoring::TDynamicCounterPtr Group;

public:
Expand Down
4 changes: 2 additions & 2 deletions ydb/core/util/concurrent_rw_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ class TConcurrentRWHashMap {
bucket.Map[key] = value;
}

V& InsertIfAbsent(const K& key, const V& value) {
V InsertIfAbsent(const K& key, const V& value) {
TBucket& bucket = GetBucketForKey(key);
TWriteGuard guard(bucket.RWLock);

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

template <typename Callable>
V& InsertIfAbsentWithInit(const K& key, Callable initFunc) {
V InsertIfAbsentWithInit(const K& key, Callable initFunc) {
TBucket& bucket = GetBucketForKey(key);
TWriteGuard guard(bucket.RWLock);

Expand Down
Loading