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(storage): Detect need for descending cursor in WindowAggregate #21140

Merged
merged 4 commits into from
Apr 5, 2021

Conversation

scbrickley
Copy link
Contributor

@scbrickley scbrickley commented Apr 5, 2021

influxdata/flux#3480

Fixes case where the storage engine was reading through shards in ascending order when it needed to read in descending order.

  • CHANGELOG.md updated with a link to the PR (not the Issue)
  • Well-formatted commit messages
  • Rebased/mergeable
  • Tests pass
  • http/swagger.yml updated (if modified Go structs or API)
  • Feature flagged (if modified API)
  • Documentation updated or issue created (provide link to issue/pr)
  • Signed CLA (if not already signed)

Copy link
Contributor

@jsternberg jsternberg left a comment

Choose a reason for hiding this comment

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

Just need to add some comments and docs and then this looks good.

import "planner"
import "csv"

testcase last_bug{
Copy link
Contributor

Choose a reason for hiding this comment

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

Format nitpick. Separate the bracket from the text.

@@ -23,6 +23,23 @@ type windowAggregateResultSet struct {
err error
}

func IsAscendingWindowAggregate(req *datatypes.ReadWindowAggregateRequest) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a doc comment.

}

if req.Aggregate[0].Type == datatypes.AggregateTypeLast {
if req.Window == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment for this section while you're here explaining the checks in this code? It wasn't here previously so no requirement but it would be nice to comment this.

@@ -71,7 +71,8 @@ func (s *Store) WindowAggregate(ctx context.Context, req *datatypes.ReadWindowAg
return nil, err
}

shardIDs, err := s.findShardIDs(database, rp, false, start, end)
ascending := reads.IsAscendingWindowAggregate(req)
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment here too since it's non-obvious what's going on here.

@danxmoran
Copy link
Contributor

Is this expected to address these issues as well?
#20595
#20486
#20722

@scbrickley
Copy link
Contributor Author

@danxmoran It should address #20486 and #20722. I am not sure if it will address #20595. I will try to confirm and get back to you.

@scbrickley
Copy link
Contributor Author

@danxmoran I believe those are all the same bug.

@philjb
Copy link
Contributor

philjb commented Apr 5, 2021

I believe I follow the logic ok. I pushed some cosmetic suggestions into this branch last-planner-bug-pjb for your consideration.

Copy link
Contributor

@jsternberg jsternberg left a comment

Choose a reason for hiding this comment

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

A few more comments. Also ensure all comments end with punctuation. Once these comments are addressed this is good to merge so pre-approving.

import "planner"
import "csv"

testcase last_bug {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry to comment on this again but can you rename this to last_multi_shard.

if nAggs := len(req.Aggregate); nAggs != 1 {
return nil, errors.Errorf(errors.InternalError, "attempt to create a windowAggregateResultSet with %v aggregate functions", nAggs)
// IsAscendingWindowAggregate checks two things: If the request passed in
// is using the `last` aggregate type, and if it has a window. If both
Copy link
Contributor

Choose a reason for hiding this comment

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

If it doesn't have a window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants