You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2022/05/15 14:57:19 UTC
[skywalking-banyandb] branch bug-ob created (now 5f38b65)
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a change to branch bug-ob
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
at 5f38b65 Fix data race of ob apis
This branch includes the following new commits:
new 5f38b65 Fix data race of ob apis
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[skywalking-banyandb] 01/01: Fix data race of ob apis
Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch bug-ob
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit 5f38b653968596a31b3d7285d51a7fbca532af6c
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Sun May 15 14:54:50 2022 +0000
Fix data race of ob apis
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