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

enforce sharding defaults in period configs #2332

Merged
merged 4 commits into from
Mar 26, 2020

Conversation

owen-d
Copy link
Contributor

@owen-d owen-d commented Mar 25, 2020

What this PR does:
This fixes a bug where the default shard factors were not set properly on PeriodConfigs. It caused us to never update the period config’s shard factor (although the derived Schema, which is used in the store, has the default shard values applied — 16 starting in v10+).

I introduced this bug while addressing the following:
#1878 (comment)

Discovery

We discovered this bug when we tried to enable querier.parallelise-shardable-queries. It effectively turned that code path into a no-op because it didn't register any shard-able PeriodConfigs (we don't specify overrides and use the derived default).

The Fix

  • Introduces a func (cfg *PeriodConfig) applyDefaults() function which mutates the associated PeriodConfig by applying default values (currently only shard factor for appropriate schemas).
  • Errors in the case of an invalid sharding configuration in each PeriodConfig.Validate()
  • Adds a number of test cases to ensure these guarantees

This should ensure that once validated , configs are safe for further use.

/cc @gouthamve @cyriltovena

Signed-off-by: Owen Diehl ow.diehl@gmail.com

owen-d added 2 commits March 25, 2020 12:32
Signed-off-by: Owen Diehl <ow.diehl@gmail.com>
Signed-off-by: Owen Diehl <ow.diehl@gmail.com>
owen-d added 2 commits March 25, 2020 13:15
Signed-off-by: Owen Diehl <ow.diehl@gmail.com>
Signed-off-by: Owen Diehl <ow.diehl@gmail.com>
Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Good job @owen-d ! LGTM. I just left a minor comment.

@@ -210,6 +214,17 @@ func (cfg PeriodConfig) validate() error {
return errInvalidTablePeriod
}

switch cfg.Schema {
case "v1", "v2", "v3", "v4", "v5", "v6", "v9":
Copy link
Contributor

Choose a reason for hiding this comment

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

Even if I guess it doesn't cause any harm, to avoid any misunderstanding/misconfiguration from the user side, shouldn't we ensure the cfg.RowShards for these schemas is 0? Am I missing anything?

Copy link
Contributor

@gouthamve gouthamve left a comment

Choose a reason for hiding this comment

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

LGTM

@pracucci pracucci merged commit 8c95bb0 into cortexproject:master Mar 26, 2020
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.

3 participants