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

Fix missing results in merged streams #342

Merged
merged 2 commits into from
Jun 16, 2023

Conversation

jotak
Copy link
Member

@jotak jotak commented Jun 13, 2023

No description provided.

@jotak jotak requested a review from jpinsonneau June 13, 2023 12:37
@jotak
Copy link
Member Author

jotak commented Jun 13, 2023

hey @jpinsonneau
I've found a bug while poc'ing around new "return traffic" feature. I easily spot the bug with my PoC but it's harder to spot it with the current state, although it is definitely here. We can chat about that if you want.

Also took this opportunity to add a couple of stats that can be useful for debugging

@codecov
Copy link

codecov bot commented Jun 13, 2023

Codecov Report

Merging #342 (3629b3d) into main (c855cf2) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #342      +/-   ##
==========================================
+ Coverage   57.87%   57.92%   +0.04%     
==========================================
  Files         150      150              
  Lines        6657     6664       +7     
  Branches      797      797              
==========================================
+ Hits         3853     3860       +7     
  Misses       2588     2588              
  Partials      216      216              
Flag Coverage Δ
uitests 58.83% <ø> (ø)
unittests 55.36% <100.00%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/model/loki.go 37.77% <ø> (ø)
pkg/loki/streams_merger.go 100.00% <100.00%> (ø)

@@ -81,9 +83,12 @@ func (m *StreamMerger) Add(from model.QueryResponseData) (model.ResultValue, err
// Add entry to the existing stream, and mark it as existing in idxStream.entries
idxStream.entries[ekey] = nil
if streamExists {
idxStream.stream.Entries = append(m.index[lkey].stream.Entries, e)
idxStream.stream.Entries = append(idxStream.stream.Entries, e)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI the bug was on this line only: append being run from a potentially outdated slice. The slice m.index[lkey].stream.Entries gets only updated at the end of the function

Copy link
Member Author

@jotak jotak Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not easy to reproduce because we need to get flows from multiple queries (ie. with OR) and same stream (same src/dst namespace, owner, direction ...); most of the time when running such queries it is too noisy to be able to accurately see that there are missing flows, without reaching the query limit.
When implementing this https://docs.google.com/document/d/14ptPh60WtZavJ2q22BpHENibvhdAD4fLRRjBsHZBVjY/edit it's much easier to reduce the search space to just 2 entitites talking to each other, and that's in this case that the bug is more visible: we get only (half +1) of the results

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(but I wrote a test that shows the problem quite explicitly) : the new test TestStreamsMerge_SameStream fails with the current code base

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense as we override the result at the end

// Add or overwrite index
m.index[lkey] = idxStream

Thanks for finding that 🥇

@jotak
Copy link
Member Author

jotak commented Jun 16, 2023

thanks @jpinsonneau :)
/approve

@openshift-ci
Copy link

openshift-ci bot commented Jun 16, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jotak

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jotak jotak added the no-qe This PR doesn't necessitate QE approval label Jun 16, 2023
@jotak jotak added the no-doc This PR doesn't require documentation change on the NetObserv operator label Jun 16, 2023
@openshift-merge-robot openshift-merge-robot merged commit d5c6c18 into netobserv:main Jun 16, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm no-doc This PR doesn't require documentation change on the NetObserv operator no-qe This PR doesn't necessitate QE approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants