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 2024/01/03 12:57:14 UTC

(skywalking-banyandb) branch measure-merger updated: Pass race check

This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch measure-merger
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


The following commit(s) were added to refs/heads/measure-merger by this push:
     new 82a5ab14 Pass race check
82a5ab14 is described below

commit 82a5ab140c54e91b5c2781eced1742fae7f0792f
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Wed Jan 3 12:56:55 2024 +0000

    Pass race check
    
    Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
 banyand/internal/storage/segment.go | 2 +-
 banyand/internal/storage/tsdb.go    | 2 +-
 banyand/measure/block.go            | 6 ++----
 banyand/measure/block_reader.go     | 2 +-
 banyand/measure/block_test.go       | 8 ++++----
 banyand/measure/gc.go               | 4 ++--
 banyand/measure/gc_test.go          | 2 +-
 banyand/measure/merger_test.go      | 2 +-
 banyand/measure/part_iter.go        | 9 ++++-----
 banyand/measure/snapshot_test.go    | 4 ++--
 banyand/measure/tstable.go          | 2 +-
 pkg/fs/local_file_system_nix.go     | 5 -----
 12 files changed, 20 insertions(+), 28 deletions(-)

diff --git a/banyand/internal/storage/segment.go b/banyand/internal/storage/segment.go
index aefd0c6e..2ec4d16b 100644
--- a/banyand/internal/storage/segment.go
+++ b/banyand/internal/storage/segment.go
@@ -117,6 +117,7 @@ func (s *segment[T]) String() string {
 
 type segmentController[T TSTable, O any] struct {
 	clock          timestamp.Clock
+	option         O
 	scheduler      *timestamp.Scheduler
 	l              *logger.Logger
 	tsTableCreator TSTableCreator[T, O]
@@ -125,7 +126,6 @@ type segmentController[T TSTable, O any] struct {
 	lst            []*segment[T]
 	segmentSize    IntervalRule
 	sync.RWMutex
-	option O
 }
 
 func newSegmentController[T TSTable, O any](ctx context.Context, location string,
diff --git a/banyand/internal/storage/tsdb.go b/banyand/internal/storage/tsdb.go
index f28c9c89..982b6a57 100644
--- a/banyand/internal/storage/tsdb.go
+++ b/banyand/internal/storage/tsdb.go
@@ -44,12 +44,12 @@ const (
 
 // TSDBOpts wraps options to create a tsdb.
 type TSDBOpts[T TSTable, O any] struct {
+	Option          O
 	TSTableCreator  TSTableCreator[T, O]
 	Location        string
 	SegmentInterval IntervalRule
 	TTL             IntervalRule
 	ShardNum        uint32
-	Option          O
 }
 
 type (
diff --git a/banyand/measure/block.go b/banyand/measure/block.go
index 8285cca0..88c40f3f 100644
--- a/banyand/measure/block.go
+++ b/banyand/measure/block.go
@@ -602,10 +602,8 @@ func releaseBlockCursor(bc *blockCursor) {
 
 type blockPointer struct {
 	block
-
-	idx int
-	bm  blockMetadata
-	// the part where the last value is from
+	bm         blockMetadata
+	idx        int
 	lastPartID uint64
 }
 
diff --git a/banyand/measure/block_reader.go b/banyand/measure/block_reader.go
index 2ba366fc..f001b009 100644
--- a/banyand/measure/block_reader.go
+++ b/banyand/measure/block_reader.go
@@ -46,10 +46,10 @@ func (r *reader) Read(p []byte) (int, error) {
 }
 
 type blockReader struct {
+	err           error
 	block         *blockPointer
 	pih           partMergeIterHeap
 	nextBlockNoop bool
-	err           error
 }
 
 func (br *blockReader) reset() {
diff --git a/banyand/measure/block_test.go b/banyand/measure/block_test.go
index d53d5baf..bb0ddf4d 100644
--- a/banyand/measure/block_test.go
+++ b/banyand/measure/block_test.go
@@ -477,10 +477,10 @@ func Test_blockPointer_append(t *testing.T) {
 		offset int
 	}
 	tests := []struct {
+		want      *blockPointer
 		name      string
-		fields    fields
 		args      args
-		want      *blockPointer
+		fields    fields
 		wantPanic bool
 	}{
 		{
@@ -783,10 +783,10 @@ func Test_blockPointer_copyFrom(t *testing.T) {
 		src *blockPointer
 	}
 	tests := []struct {
-		name   string
-		fields fields
 		args   args
 		want   *blockPointer
+		name   string
+		fields fields
 	}{
 		{
 			name: "Test copyFrom",
diff --git a/banyand/measure/gc.go b/banyand/measure/gc.go
index ceff85cb..05673541 100644
--- a/banyand/measure/gc.go
+++ b/banyand/measure/gc.go
@@ -23,10 +23,10 @@ import (
 
 type garbageCleaner struct {
 	parent          *tsTable
-	liveEpoch       uint64
-	deletableEpochs []uint64
 	liveParts       map[uint64]map[uint64]struct{}
 	knownPartFiles  map[uint64]struct{}
+	deletableEpochs []uint64
+	liveEpoch       uint64
 }
 
 func (g *garbageCleaner) init(parent *tsTable) {
diff --git a/banyand/measure/gc_test.go b/banyand/measure/gc_test.go
index e77aebdb..e31dc46e 100644
--- a/banyand/measure/gc_test.go
+++ b/banyand/measure/gc_test.go
@@ -28,9 +28,9 @@ import (
 func TestDeletableEpochs(t *testing.T) {
 	tests := []struct {
 		name            string
-		n               int
 		knownEpochs     []uint64
 		deletableEpochs []uint64
+		n               int
 	}{
 		{
 			name:            "empty",
diff --git a/banyand/measure/merger_test.go b/banyand/measure/merger_test.go
index b4216579..2c92b3eb 100644
--- a/banyand/measure/merger_test.go
+++ b/banyand/measure/merger_test.go
@@ -33,10 +33,10 @@ import (
 
 func Test_mergeTwoBlocks(t *testing.T) {
 	tests := []struct {
-		name  string
 		left  *blockPointer
 		right *blockPointer
 		want  *blockPointer
+		name  string
 	}{
 		{
 			name:  "Merge two empty blocks",
diff --git a/banyand/measure/part_iter.go b/banyand/measure/part_iter.go
index 2921ce26..4f494598 100644
--- a/banyand/measure/part_iter.go
+++ b/banyand/measure/part_iter.go
@@ -237,14 +237,13 @@ func (pi *partIter) findBlock() bool {
 }
 
 type partMergeIter struct {
-	err                error
-	p                  *part
-	primaryMetadataIdx int
-
+	err                  error
+	p                    *part
 	compressedPrimaryBuf []byte
 	primaryBuf           []byte
-	block                blockPointer
 	columnValuesDecoder  encoding.BytesBlockDecoder
+	block                blockPointer
+	primaryMetadataIdx   int
 }
 
 func (pmi *partMergeIter) reset() {
diff --git a/banyand/measure/snapshot_test.go b/banyand/measure/snapshot_test.go
index bf399ac3..80cf41b1 100644
--- a/banyand/measure/snapshot_test.go
+++ b/banyand/measure/snapshot_test.go
@@ -290,11 +290,11 @@ func TestSnapshotMerge(t *testing.T) {
 
 func TestSnapshotRemove(t *testing.T) {
 	tests := []struct {
-		name        string
 		snapshot    *snapshot
-		nextEpoch   uint64
 		mergedParts map[uint64]struct{}
+		name        string
 		expected    snapshot
+		nextEpoch   uint64
 		closePrev   bool
 	}{
 		{
diff --git a/banyand/measure/tstable.go b/banyand/measure/tstable.go
index b9bbb425..80b93ebd 100644
--- a/banyand/measure/tstable.go
+++ b/banyand/measure/tstable.go
@@ -112,11 +112,11 @@ type tsTable struct {
 	snapshot      *snapshot
 	introductions chan *introduction
 	loopCloser    *run.Closer
+	p             common.Position
 	root          string
 	gc            garbageCleaner
 	curPartID     uint64
 	option        option
-	p             common.Position
 	sync.RWMutex
 }
 
diff --git a/pkg/fs/local_file_system_nix.go b/pkg/fs/local_file_system_nix.go
index f8aef20d..75db2649 100644
--- a/pkg/fs/local_file_system_nix.go
+++ b/pkg/fs/local_file_system_nix.go
@@ -33,11 +33,6 @@ func (*localFileSystem) CreateLockFile(name string, permission Mode) (File, erro
 	switch {
 	case err == nil:
 		if err = unix.Flock(int(file.Fd()), unix.LOCK_EX|unix.LOCK_NB); err != nil {
-			// if errors.Is(err, syscall.EAGAIN) {
-			// 	return &LocalFile{
-			// 		file: file,
-			// 	}, nil
-			// }
 			return nil, &FileSystemError{
 				Code:    lockError,
 				Message: fmt.Sprintf("Cannot lock file, file name: %s, error message: %s", name, err),