You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2022/05/15 15:04:04 UTC
[skywalking-banyandb] branch main updated: Fix data race of ob apis (#116)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/main by this push:
new 9f540a7 Fix data race of ob apis (#116)
9f540a7 is described below
commit 9f540a7c144108752da7939bb851a454cd59c08d
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Sun May 15 23:04:00 2022 +0800
Fix data race of ob apis (#116)
Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
pkg/index/inverted/field_map.go | 2 ++
pkg/index/inverted/term_map.go | 2 ++
2 files changed, 4 insertions(+)
diff --git a/pkg/index/inverted/field_map.go b/pkg/index/inverted/field_map.go
index 9b719e0..0f354e7 100644
--- a/pkg/index/inverted/field_map.go
+++ b/pkg/index/inverted/field_map.go
@@ -74,6 +74,8 @@ func (fm *fieldMap) put(fv index.Field, id common.ItemID) error {
}
func (fm *fieldMap) Stats() (s observability.Statistics) {
+ fm.mutex.RLock()
+ defer fm.mutex.RUnlock()
for _, pv := range fm.repo {
// 8 is the size of key
s.MemBytes += 8
diff --git a/pkg/index/inverted/term_map.go b/pkg/index/inverted/term_map.go
index a3d9adb..42a10b7 100644
--- a/pkg/index/inverted/term_map.go
+++ b/pkg/index/inverted/term_map.go
@@ -85,6 +85,8 @@ func (p *termMap) getEntry(key []byte) *index.PostingValue {
}
func (p *termMap) Stats() (s observability.Statistics) {
+ p.mutex.RLock()
+ defer p.mutex.RUnlock()
for _, pv := range p.repo {
// 8 is the size of key
s.MemBytes += 8