This is an automated email from the ASF dual-hosted git repository. hanahmily pushed a commit to branch topn-entity in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit a3464aff95e673a89bf0af4a48843b76094ec15c Author: Gao Hongtao <hanahm...@gmail.com> AuthorDate: Tue May 14 07:55:44 2024 +0800 Fix topn query nil and add more context to err Signed-off-by: Gao Hongtao <hanahm...@gmail.com> --- banyand/internal/storage/index.go | 6 ++- banyand/query/processor_topn.go | 1 + pkg/index/index.go | 18 +++++++++ test/stress/vm/Makefile | 38 ++++++++++++++++++ test/stress/vm/docker-compose.yaml | 80 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 142 insertions(+), 1 deletion(-) diff --git a/banyand/internal/storage/index.go b/banyand/internal/storage/index.go index ce67627e..950d1640 100644 --- a/banyand/internal/storage/index.go +++ b/banyand/internal/storage/index.go @@ -101,7 +101,11 @@ func (s *seriesIndex) searchPrimary(ctx context.Context, series []*pbv1.Series) if err != nil { return nil, err } - return convertIndexSeriesToSeriesList(ss) + result, err := convertIndexSeriesToSeriesList(ss) + if err != nil { + return nil, errors.WithMessagef(err, "failed to convert index series to series list, matchers: %v, result:%v", seriesMatchers, ss) + } + return result, nil } var emptySeriesMatcher = index.SeriesMatcher{} diff --git a/banyand/query/processor_topn.go b/banyand/query/processor_topn.go index 8e64169f..99dc8b42 100644 --- a/banyand/query/processor_topn.go +++ b/banyand/query/processor_topn.go @@ -121,6 +121,7 @@ func (t *topNQueryProcessor) Rev(message bus.Message) (resp bus.Message) { if err != nil { ml.Error().Err(err).RawJSON("req", logger.Proto(request)).Msg("fail to close the topn plan") resp = bus.NewMessage(bus.MessageID(now), common.NewError("fail to execute the topn plan for measure %s: %v", topNMetadata.GetName(), err)) + return } defer func() { if err = mIterator.Close(); err != nil { diff --git a/pkg/index/index.go b/pkg/index/index.go index 106ccaa4..92b5efa3 100644 --- a/pkg/index/index.go +++ b/pkg/index/index.go @@ -237,6 +237,10 @@ type Series struct { ID common.SeriesID } +func (s Series) String() string { + return fmt.Sprintf("%s:%d", s.EntityValues, s.ID) +} + // SeriesStore is an abstract of a series repository. type SeriesStore interface { Store @@ -262,6 +266,20 @@ type SeriesMatcher struct { Type SeriesMatcherType } +// String returns a string representation of the series matcher. +func (s SeriesMatcher) String() string { + switch s.Type { + case SeriesMatcherTypeExact: + return fmt.Sprintf("exact:%s", s.Match) + case SeriesMatcherTypePrefix: + return fmt.Sprintf("prefix:%s", s.Match) + case SeriesMatcherTypeWildcard: + return fmt.Sprintf("wildcard:%s", s.Match) + default: + return fmt.Sprintf("unknown:%s", s.Match) + } +} + // GetSearcher returns a searcher associated with input index rule type. type GetSearcher func(location databasev1.IndexRule_Type) (Searcher, error) diff --git a/test/stress/vm/Makefile b/test/stress/vm/Makefile new file mode 100644 index 00000000..43eb4a21 --- /dev/null +++ b/test/stress/vm/Makefile @@ -0,0 +1,38 @@ +# 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. +# + +NAME := vm + +CLI_ARGS := + +ifdef PROFILE + CLI_ARGS := $(CLI_ARGS) --profile $(PROFILE) +endif + +cli_env := DOCKER_BUILDKIT=1 USER_ID=$(shell id -u) GROUP_ID=$(shell id -g) + +.PHONY: clean +clean: + rm -rf /tmp/banyandb-stress-vm + +up: clean + $(cli_env) docker compose -f docker-compose.yaml $(CLI_ARGS) up --build + +down: + docker compose -f docker-compose.yaml down + \ No newline at end of file diff --git a/test/stress/vm/docker-compose.yaml b/test/stress/vm/docker-compose.yaml new file mode 100644 index 00000000..b7e79cd6 --- /dev/null +++ b/test/stress/vm/docker-compose.yaml @@ -0,0 +1,80 @@ +version: '3.8' +services: + change-vol-ownership: + image: ubuntu + user: "root" + group_add: + - '${GROUP_ID}' + volumes: + - /tmp/banyandb-stress-vm:/tmp/change-ownership + command: chown -R ${USER_ID}:${GROUP_ID} /tmp/change-ownership + + banyandb: + user: "${USER_ID}:${GROUP_ID}" + extends: + file: ../../docker/base-compose.yml + service: banyandb + build: + dockerfile: ./docker/Dockerfile + context: ../../.. + volumes: + - /tmp/banyandb-stress-vm:/tmp:rw,delgated + ports: + - 17913:17913 + - 6060:6060 + - 2121:2121 + networks: + - skywalking + depends_on: + change-vol-ownership: + condition: service_completed_successfully + + oap: + container_name: skywalking-server-bdb + image: ${OAP_IMAGE:-ghcr.io/apache/skywalking/oap:latest} + ports: + - "11800:11800" + - "12800:12800" + - "9099:9090" + - "3100:3100" + networks: + - skywalking + healthcheck: + test: [ "CMD-SHELL", "curl http://localhost:12800/internal/l7check" ] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s +# restart: always + environment: &oap-env + TZ: Europe/Moscow + SW_HEALTH_CHECKER: default + SW_OTEL_RECEIVER: default + SW_OTEL_RECEIVER_ENABLED_OC_RULES: vm + SW_OTEL_RECEIVER_ENABLED_OTEL_METRICS_RULES: vm + SW_TELEMETRY: prometheus + JAVA_OPTS: "-Xms2048m -Xmx2048m" + SW_STORAGE: banyandb + SW_STORAGE_BANYANDB_TARGETS: banyandb:17912 + SW_CORE_RECORD_DATA_TTL: 14 # https://skywalking.apache.org/docs/main/next/en/setup/backend/ttl/ + SW_CORE_METRICS_DATA_TTL: 14 + SW_DCS_MAX_INBOUND_MESSAGE_SIZE: 5000000000 + depends_on: + banyandb: + condition: service_healthy + + ui: + image: ${UI_IMAGE:-ghcr.io/apache/skywalking/ui:latest} + container_name: skywalking-ui + ports: + - "1010:8080" + networks: + - skywalking + restart: always + environment: + <<: *oap-env + SW_OAP_ADDRESS: http://skywalking-server-bdb:12800 + SW_ZIPKIN_ADDRESS: http://skywalking-server-bdb:9412 + +networks: + skywalking: \ No newline at end of file