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 data query option allow_past to correctly work in memory mode ram and save #12136

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

stelfrag
Copy link
Collaborator

Summary

Fixes product@12135

when using the allow_past option in data queries and the agent memory mode is ram or save it will not
correctly detect that the after timestamp requested may be out of range, attempting to map the requested
time in invalid locations in the buffer.

Test Plan
  • Start an agent in memory mode RAM and immediately
    • Run a query api/v1/data?chart=system.cpu&after=-60&options=jsonwrap
      • You should only see a few points being returned
    • Run a query api/v1/data?chart=system.cpu&after=-60&options=jsonwrap|allow_past
      • You will see 60 points returned but the results will be inconsistent; you may get null values for recent timestamps which is wrong
  • After applying the PR, run the above tests
    • You will notice that the agent will correctly generate NULL values for the time range that metrics were not collected

@stelfrag stelfrag marked this pull request as ready for review February 15, 2022 13:52
Copy link
Contributor

@thiagoftsm thiagoftsm left a comment

Choose a reason for hiding this comment

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

The tests demonstrate the expected result. LGTM!

Copy link
Contributor

@odynik odynik left a comment

Choose a reason for hiding this comment

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

Test results looks good!
/api/v1/data?chart=system.cpu&after=-600&options=jsonwrap

      [ 1645003231, 0, 0, 0.2554278, 0.2554278, 0, 29.11877, 42.78416, 0, 13.793103],
      [ 1645003230, 0, 0, 0.0579467, 0.0579467, 0, 6.605922, 9.70607, 0, 3.129121]
  ]

/api/v1/data?chart=system.cpu&after=-60&options=jsonwrap|allow_past

      [ 1645003231, 0, 0, 0.2554278, 0.2554278, 0, 29.11877, 42.78416, 0, 13.793103],
      [ 1645003230, 0, 0, 0.0579467, 0.0579467, 0, 6.605922, 9.70607, 0, 3.129121],
      [ 1645003229, null, null, null, null, null, null, null, null, null],
      [ 1645003228, null, null, null, null, null, null, null, null, null],

@stelfrag stelfrag merged commit 15dd0e4 into netdata:master Feb 17, 2022
@stelfrag stelfrag deleted the fix_allow_past_ram_save branch February 18, 2022 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Data queries discrepancy
4 participants