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 2024/05/21 00:13:55 UTC

(skywalking-banyandb) branch main updated: Data race in the hot series index selection. (#448)

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 dd064001 Data race in the hot series index selection. (#448)
dd064001 is described below

commit dd064001ae9151dbbff9207df00d85fda00092c3
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Tue May 21 08:13:50 2024 +0800

    Data race in the hot series index selection. (#448)
---
 CHANGES.md                        | 1 +
 banyand/internal/storage/index.go | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/CHANGES.md b/CHANGES.md
index ebd0fce5..2c3ae774 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -9,6 +9,7 @@ Release Notes.
 ### Bugs
 
 - Fix the bug that topN query doesn't return when an error occurs.
+- Data race in the hot series index selection.
 
 ## 0.6.0
 
diff --git a/banyand/internal/storage/index.go b/banyand/internal/storage/index.go
index 950d1640..1ac969f4 100644
--- a/banyand/internal/storage/index.go
+++ b/banyand/internal/storage/index.go
@@ -42,7 +42,7 @@ import (
 )
 
 func (d *database[T, O]) IndexDB() IndexDB {
-	return d.indexController.hot
+	return d.indexController.getHot()
 }
 
 func (d *database[T, O]) Lookup(ctx context.Context, series []*pbv1.Series) (pbv1.SeriesList, error) {
@@ -310,6 +310,12 @@ func newSeriesIndexController[T TSTable, O any](
 	return sic, nil
 }
 
+func (sic *seriesIndexController[T, O]) getHot() *seriesIndex {
+	sic.RLock()
+	defer sic.RUnlock()
+	return sic.hot
+}
+
 func (sic *seriesIndexController[T, O]) loadIdx() ([]string, error) {
 	idxName := make([]string, 0)
 	if err := walkDir(