Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag Search is working incorrectly with badger #1808

Closed
zerda opened this issue Sep 22, 2019 · 3 comments
Closed

Tag Search is working incorrectly with badger #1808

zerda opened this issue Sep 22, 2019 · 3 comments
Labels
storage/badger Issues related to badger storage

Comments

@zerda
Copy link

zerda commented Sep 22, 2019

Problem - what in Jaeger blocks you from solving the requirement?

I'm using nginx ingress controller integrated with Jaeger (badger storage).

When searching with http.request_id tag, the result is incorrectly empty.

Here is an unit test to reproduce this issue.

func TestRandomTraceID(t *testing.T) {
	runFactoryTest(t, func(tb testing.TB, sw spanstore.Writer, sr spanstore.Reader) {
		s1 := model.Span{
			TraceID: model.TraceID{
				Low:  uint64(14767110704788176287),
				High: 0,
			},
			SpanID: model.SpanID(14976775253976086374),
			OperationName: "/",
			Process: &model.Process{
				ServiceName: "nginx",
			},
			Tags: model.KeyValues{
				model.KeyValue{
					Key:   "http.request_id",
					VStr:  "first",
					VType: model.StringType,
				},
			},
			StartTime: time.Now(),
			Duration:  1 * time.Second,
		}
		err := sw.WriteSpan(&s1)

		s2 := model.Span{
			TraceID: model.TraceID{
				Low:  uint64(4775132888371984950),
				High: 0,
			},
			SpanID: model.SpanID(13576481569227028654),
			OperationName: "/",
			Process: &model.Process{
				ServiceName: "nginx",
			},
			Tags: model.KeyValues{
				model.KeyValue{
					Key:   "http.request_id",
					VStr:  "second",
					VType: model.StringType,
				},
			},
			StartTime: time.Now(),
			Duration:  1 * time.Second,
		}
		err = sw.WriteSpan(&s2)

		params := &spanstore.TraceQueryParameters{
			StartTimeMin: time.Now().Add(-1 * time.Minute),
			StartTimeMax: time.Now(),
			ServiceName:  "nginx",
			Tags: map[string]string{
				"http.request_id": "second",
			},
		}
		traces, err := sr.FindTraces(context.Background(), params)
		assert.NoError(t, err)

                 // failed with `second` tag query, but success with `first`
		assert.Equal(t, 1, len(traces))
	})
}

And here are the traces produced by nginx. nginx-traces.zip

Proposal - what do you suggest to solve the problem or improve the existing situation?

Maybe it's about TraceID (the first traceID is large than the second one), and mergeJoinIds function is not handled this correclty.

@zerda
Copy link
Author

zerda commented Sep 22, 2019

@burmanm Any thoughts?

@burmanm
Copy link
Contributor

burmanm commented Sep 22, 2019

@zerda It's not actually in the mergeJoinIds, but the index seek code. TraceIDs are correctly sorted, however the actual data is stored as sorted by timestamp first and not TraceID which causes this error.

And none of the unit tests catched this as they had time in the same order as ids (in tests that mattered). The index seek logging reveals this:

scanIndexKeys result:

[129 110 103 105 110 120 0 5 147 31 147 93 187 194 0 0 0 0 0 0 0 0 204 239 80 242 77 196 125 159]
[129 110 103 105 110 120 0 5 147 31 147 93 191 207 0 0 0 0 0 0 0 0 66 68 174 15 238 178 122 54]

Parsed traceIDs:

TraceID: [0 0 0 0 0 0 0 0 204 239 80 242 77 196 125 159]
TraceID: [0 0 0 0 0 0 0 0 66 68 174 15 238 178 122 54]

I'll have to add sort back to that scanIndexKeys method (after duplicate removal).

@burmanm
Copy link
Contributor

burmanm commented Sep 22, 2019

Thanks for catching this, I'll fix it tomorrow.

burmanm added a commit to burmanm/jaeger that referenced this issue Sep 23, 2019
@pavolloffay pavolloffay added the storage/badger Issues related to badger storage label Sep 23, 2019
burmanm added a commit to burmanm/jaeger that referenced this issue Sep 23, 2019
burmanm added a commit to burmanm/jaeger that referenced this issue Sep 23, 2019
radekg pushed a commit to Klarrio/jaeger that referenced this issue Oct 28, 2019
…cing#1808 (jaegertracing#1809)

* Fix ordering of indexScanKeys after TraceID parsing, closes jaegertracing#1808

Signed-off-by: Michael Burman <yak@iki.fi>

* Address comments

Signed-off-by: Michael Burman <yak@iki.fi>

* ..

Signed-off-by: Michael Burman <yak@iki.fi>
Signed-off-by: radekg <radek@gruchalski.com>
backjo pushed a commit to backjo/jaeger that referenced this issue Dec 19, 2019
…cing#1808 (jaegertracing#1809)

* Fix ordering of indexScanKeys after TraceID parsing, closes jaegertracing#1808

Signed-off-by: Michael Burman <yak@iki.fi>

* Address comments

Signed-off-by: Michael Burman <yak@iki.fi>

* ..

Signed-off-by: Michael Burman <yak@iki.fi>
Signed-off-by: Jonah Back <jonah@jonahback.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
storage/badger Issues related to badger storage
Projects
None yet
Development

No branches or pull requests

3 participants