From e1b83d27b01fb81f6b64876dc470643c62f16260 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Tue, 29 Oct 2019 11:03:35 -0400 Subject: [PATCH 1/5] Decouple storage dependencies Signed-off-by: Yuri Shkuro --- cmd/flags/flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/flags/flags.go b/cmd/flags/flags.go index 78522f23579..569be0e81f8 100644 --- a/cmd/flags/flags.go +++ b/cmd/flags/flags.go @@ -62,7 +62,7 @@ type logging struct { // AddFlags adds flags for SharedFlags func AddFlags(flagSet *flag.FlagSet) { - flagSet.String(spanStorageType, "", fmt.Sprintf(`(deprecated) please use %s environment variable. Run this binary with "env" command for help.`, storage.SpanStorageTypeEnvVar)) + flagSet.String(spanStorageType, "", "(deprecated) please use SPAN_STORAGE_TYPE environment variable. Run this binary with "env" command for help.") AddLoggingFlag(flagSet) } From b576dd7092fbab0afccaaf180298c79b2dd4cb6d Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Tue, 29 Oct 2019 11:20:15 -0400 Subject: [PATCH 2/5] Bump Go version to 1.13.x Signed-off-by: Yuri Shkuro --- .travis.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 49bea5353e5..4b4275142a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,43 +7,43 @@ dist: trusty jobs: include: - - go: "1.12.1" + - go: "1.13.x" env: - TESTS=true - COVERAGE=true - - go: "1.12.1" + - go: "1.13.x" env: - PROTO_GEN_TEST=true - - go: "1.12.1" + - go: "1.13.x" env: - ALL_IN_ONE=true - - go: "1.12.1" + - go: "1.13.x" env: - CROSSDOCK=true - - go: "1.12.1" + - go: "1.13.x" env: - DOCKER=true - DEPLOY=true - - go: "1.12.1" + - go: "1.13.x" env: - ES_INTEGRATION_TEST=true - - go: "1.12.1" + - go: "1.13.x" env: - KAFKA_INTEGRATION_TEST=true - - go: "1.12.1" + - go: "1.13.x" env: - CASSANDRA_INTEGRATION_TEST=true - - go: "1.12.1" + - go: "1.13.x" env: - HOTROD=true - stage: Fuzz regression dist: bionic - go: 1.12.x + go: "1.13.x" script: ./scripts/travis/fuzzit.sh local-regression - stage: Fuzz if: branch = master AND type IN (push) dist: bionic - go: 1.12.x + go: "1.13.x" script: ./scripts/travis/fuzzit.sh fuzzing services: From 2a2f5e36cd53719f35eaed14d9b743dbafab586f Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Tue, 29 Oct 2019 11:29:17 -0400 Subject: [PATCH 3/5] Fix quotes Signed-off-by: Yuri Shkuro --- cmd/flags/flags.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cmd/flags/flags.go b/cmd/flags/flags.go index 569be0e81f8..ecc364f5651 100644 --- a/cmd/flags/flags.go +++ b/cmd/flags/flags.go @@ -17,14 +17,10 @@ package flags import ( "flag" - "fmt" - "github.com/pkg/errors" "github.com/spf13/viper" "go.uber.org/zap" "go.uber.org/zap/zapcore" - - "github.com/jaegertracing/jaeger/plugin/storage" ) const ( @@ -62,7 +58,7 @@ type logging struct { // AddFlags adds flags for SharedFlags func AddFlags(flagSet *flag.FlagSet) { - flagSet.String(spanStorageType, "", "(deprecated) please use SPAN_STORAGE_TYPE environment variable. Run this binary with "env" command for help.") + flagSet.String(spanStorageType, "", "(deprecated) please use SPAN_STORAGE_TYPE environment variable. Run this binary with the 'env' command for help.") AddLoggingFlag(flagSet) } From e257452b89714f7a33b29362ce0b4e391f30204f Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Tue, 29 Oct 2019 11:43:36 -0400 Subject: [PATCH 4/5] Force go modules off Signed-off-by: Yuri Shkuro --- .travis.yml | 1 + Makefile | 4 ++-- cmd/flags/flags.go | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4b4275142a7..b827a7541b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,6 +51,7 @@ services: env: global: + - GO111MODULE=off - DOCKER_COMPOSE_VERSION=1.8.0 - COMMIT=${TRAVIS_COMMIT::8} # DOCKER_USER diff --git a/Makefile b/Makefile index d3326136a52..8e49043d1e9 100644 --- a/Makefile +++ b/Makefile @@ -136,13 +136,13 @@ fmt: .PHONY: lint-gosec lint-gosec: - $(GOSEC) ./... + time $(GOSEC) ./... .PHONY: lint-staticcheck lint-staticcheck: @echo Running staticcheck... @cat /dev/null > $(LINT_LOG) - @$(STATICCHECK) ./... \ + @time $(STATICCHECK) ./... \ | grep -v \ -e model/model.pb.go \ -e thrift-gen/ \ diff --git a/cmd/flags/flags.go b/cmd/flags/flags.go index ecc364f5651..32838395cb3 100644 --- a/cmd/flags/flags.go +++ b/cmd/flags/flags.go @@ -17,6 +17,7 @@ package flags import ( "flag" + "github.com/pkg/errors" "github.com/spf13/viper" "go.uber.org/zap" From b41ae0267c5bd5169501bb3bcd066fa164ba1fa5 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Tue, 29 Oct 2019 12:38:19 -0400 Subject: [PATCH 5/5] Fix data race Signed-off-by: Yuri Shkuro --- plugin/storage/memory/memory.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/plugin/storage/memory/memory.go b/plugin/storage/memory/memory.go index f4fc9f22d00..d4aaa4c98da 100644 --- a/plugin/storage/memory/memory.go +++ b/plugin/storage/memory/memory.go @@ -150,11 +150,19 @@ func (m *Store) WriteSpan(span *model.Span) error { func (m *Store) GetTrace(ctx context.Context, traceID model.TraceID) (*model.Trace, error) { m.RLock() defer m.RUnlock() - retMe := m.traces[traceID] - if retMe == nil { + trace, ok := m.traces[traceID] + if !ok { return nil, spanstore.ErrTraceNotFound } - return retMe, nil + return m.copyTrace(trace), nil +} + +// Spans may still be added to traces after they are returned to user code, so make copies. +func (m *Store) copyTrace(trace *model.Trace) *model.Trace { + return &model.Trace{ + Spans: append([]*model.Span(nil), trace.Spans...), + Warnings: append([]string(nil), trace.Warnings...), + } } // GetServices returns a list of all known services @@ -172,14 +180,13 @@ func (m *Store) GetServices(ctx context.Context) ([]string, error) { func (m *Store) GetOperations(ctx context.Context, service string) ([]string, error) { m.RLock() defer m.RUnlock() + var retMe []string if operations, ok := m.operations[service]; ok { - var retMe []string for ops := range operations { retMe = append(retMe, ops) } - return retMe, nil } - return []string{}, nil + return retMe, nil } // FindTraces returns all traces in the query parameters are satisfied by a trace's span @@ -189,7 +196,7 @@ func (m *Store) FindTraces(ctx context.Context, query *spanstore.TraceQueryParam var retMe []*model.Trace for _, trace := range m.traces { if m.validTrace(trace, query) { - retMe = append(retMe, trace) + retMe = append(retMe, m.copyTrace(trace)) } }