You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "hanahmily (via GitHub)" <gi...@apache.org> on 2025/07/16 05:40:53 UTC

[PR] Introduce write queue mechanism in liaison nodes [skywalking-banyandb]

hanahmily opened a new pull request, #705:
URL: https://github.com/apache/skywalking-banyandb/pull/705

   
   - [x] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Fixes apache/skywalking#12870, apache/skywalking#13288.
   - [x] Update the [`CHANGES` log](https://github.com/apache/skywalking-banyandb/blob/main/CHANGES.md).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce write queue mechanism in liaison nodes [skywalking-banyandb]

Posted by "hanahmily (via GitHub)" <gi...@apache.org>.
hanahmily merged PR #705:
URL: https://github.com/apache/skywalking-banyandb/pull/705


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce write queue mechanism in liaison nodes [skywalking-banyandb]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #705:
URL: https://github.com/apache/skywalking-banyandb/pull/705#discussion_r2209287668


##########
banyand/measure/svc_data.go:
##########
@@ -0,0 +1,421 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package measure
+
+import (
+	"context"
+	"fmt"
+	"path"
+	"path/filepath"
+	"strings"
+	"sync"
+	"time"
+
+	"github.com/pkg/errors"
+	"go.uber.org/multierr"
+
+	"github.com/apache/skywalking-banyandb/api/common"
+	"github.com/apache/skywalking-banyandb/api/data"
+	commonv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/common/v1"
+	databasev1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1"
+	measurev1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/measure/v1"
+	"github.com/apache/skywalking-banyandb/banyand/internal/storage"
+	"github.com/apache/skywalking-banyandb/banyand/metadata"
+	"github.com/apache/skywalking-banyandb/banyand/metadata/schema"
+	"github.com/apache/skywalking-banyandb/banyand/observability"
+	"github.com/apache/skywalking-banyandb/banyand/protector"
+	"github.com/apache/skywalking-banyandb/banyand/queue"
+	"github.com/apache/skywalking-banyandb/pkg/bus"
+	"github.com/apache/skywalking-banyandb/pkg/fs"
+	"github.com/apache/skywalking-banyandb/pkg/logger"
+	"github.com/apache/skywalking-banyandb/pkg/meter/native"
+	"github.com/apache/skywalking-banyandb/pkg/run"
+	resourceSchema "github.com/apache/skywalking-banyandb/pkg/schema"
+	"github.com/apache/skywalking-banyandb/pkg/timestamp"
+)
+
+const (
+	serviceName = "measure"
+)
+
+var _ Service = (*dataSVC)(nil)
+
+type dataSVC struct {
+	lfs                 fs.FileSystem
+	c                   storage.Cache
+	pipeline            queue.Server
+	omr                 observability.MetricsRegistry
+	metadata            metadata.Repo
+	pm                  protector.Memory
+	metricPipeline      queue.Server
+	schemaRepo          *schemaRepo
+	l                   *logger.Logger
+	cm                  *cacheMetrics
+	root                string
+	dataPath            string
+	snapshotDir         string
+	option              option
+	cc                  storage.CacheConfig
+	maxDiskUsagePercent int
+	maxFileSnapshotNum  int
+}
+
+func (s *dataSVC) Measure(metadata *commonv1.Metadata) (Measure, error) {
+	sm, ok := s.schemaRepo.loadMeasure(metadata)
+	if !ok {
+		return nil, errors.WithStack(ErrMeasureNotExist)
+	}
+	return sm, nil
+}
+
+func (s *dataSVC) LoadGroup(name string) (resourceSchema.Group, bool) {
+	return s.schemaRepo.LoadGroup(name)
+}
+
+func (s *dataSVC) GetRemovalSegmentsTimeRange(group string) *timestamp.TimeRange {
+	return s.schemaRepo.GetRemovalSegmentsTimeRange(group)
+}
+
+func (s *dataSVC) FlagSet() *run.FlagSet {
+	flagS := run.NewFlagSet("storage")
+	flagS.StringVar(&s.root, "measure-root-path", "/tmp", "the root path of measure")
+	flagS.StringVar(&s.dataPath, "measure-data-path", "", "the data directory path of measure. If not set, <measure-root-path>/measure/data will be used")
+	flagS.DurationVar(&s.option.flushTimeout, "measure-flush-timeout", defaultFlushTimeout, "the memory data timeout of measure")
+	s.option.mergePolicy = newDefaultMergePolicy()
+	flagS.VarP(&s.option.mergePolicy.maxFanOutSize, "measure-max-fan-out-size", "", "the upper bound of a single file size after merge of measure")
+	s.option.seriesCacheMaxSize = run.Bytes(32 << 20)
+	flagS.VarP(&s.option.seriesCacheMaxSize, "measure-series-cache-max-size", "", "the max size of series cache in each group")
+	flagS.IntVar(&s.maxDiskUsagePercent, "measure-max-disk-usage-percent", 95, "the maximum disk usage percentage allowed")
+	flagS.IntVar(&s.maxFileSnapshotNum, "measure-max-file-snapshot-num", 10, "the maximum number of file snapshots allowed")
+	s.cc.MaxCacheSize = run.Bytes(100 * 1024 * 1024)
+	flagS.VarP(&s.cc.MaxCacheSize, "service-cache-max-size", "", "maximum service cache size (e.g., 100M)")
+	flagS.DurationVar(&s.cc.CleanupInterval, "service-cache-cleanup-interval", 30*time.Second, "service cache cleanup interval")
+	flagS.DurationVar(&s.cc.IdleTimeout, "service-cache-idle-timeout", 2*time.Minute, "service cache entry idle timeout")
+	return flagS
+}
+
+func (s *dataSVC) Validate() error {
+	if s.root == "" {
+		return errEmptyRootPath
+	}
+	if s.maxDiskUsagePercent < 0 {
+		return errors.New("measure-max-disk-usage-percen must be greater than or equal to 0")
+	}
+	if s.maxDiskUsagePercent > 100 {
+		return errors.New("measure-max-disk-usage-percen must be less than or equal to 100")

Review Comment:
   Fix the typo in the error message: "measure-max-disk-usage-percen" should be "measure-max-disk-usage-percent".
   ```suggestion
   		return errors.New("measure-max-disk-usage-percent must be greater than or equal to 0")
   	}
   	if s.maxDiskUsagePercent > 100 {
   		return errors.New("measure-max-disk-usage-percent must be less than or equal to 100")
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org