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

Enable bucket index by default #924

Merged
merged 7 commits into from
Feb 7, 2022
Merged

Enable bucket index by default #924

merged 7 commits into from
Feb 7, 2022

Conversation

andyasp
Copy link
Contributor

@andyasp andyasp commented Jan 27, 2022

What this PR does:

Enables the bucket index by default

WIP: Looking into the test failures

Which issue(s) this PR fixes:

Fixes https://github.com/grafana/mimir-squad/issues/498

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@pracucci
Copy link
Collaborator

Thanks for working on this! I agree on enabling it by default. Changing all integration tests could be annoying (and would make them even more fragile cause we have to run compactor, wait for it, ...). I would suggest to selectively disable -blocks-storage.bucket-store.bucket-index.enabled in integration tests querying the long-term storage where it's not already enabled.

@andyasp
Copy link
Contributor Author

andyasp commented Jan 28, 2022

I'll work on this PR next week. I'm having some issues running integration tests locally that I still haven't been able to resolve.

@pracucci
Copy link
Collaborator

I'll work on this PR next week. I'm having some issues running integration tests locally that I still haven't been able to resolve.

Feel free to reach out if you need help.

@andyasp andyasp force-pushed the aasp/enable-bucket-index branch 2 times, most recently from 843f946 to 208efc3 Compare February 2, 2022 18:12
@andyasp
Copy link
Contributor Author

andyasp commented Feb 2, 2022

I was able to iterate on the integration tests locally. They still fail when trying to run too many at once, but that wasn't a blocker here. Thanks to @treid314 for helping me look at the last unit test failure, which was an interaction with a mock not expecting index read attempts.

@andyasp andyasp marked this pull request as ready for review February 2, 2022 18:30
pkg/storage/tsdb/config.go Outdated Show resolved Hide resolved
pkg/storegateway/gateway_test.go Outdated Show resolved Hide resolved
@andyasp andyasp force-pushed the aasp/enable-bucket-index branch 3 times, most recently from 36dd1c0 to ad7f7e2 Compare February 3, 2022 15:06
@pracucci pracucci self-requested a review February 3, 2022 15:50
Copy link
Collaborator

@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! I left few minor comments I would be glad to see addressed before we merge it.

@@ -434,5 +434,7 @@

// Bucket index is updated by compactor on each cleanup cycle.
'blocks-storage.bucket-store.sync-interval': $._config.compactor_cleanup_interval,
} else {},
} else {
'blocks-storage.bucket-store.bucket-index.enabled': false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would do the opposite in our jsonnet. If bucket_index_enabled is true (and you change the default it to true) then we don't add blocks-storage.bucket-store.bucket-index.enabled': true, because that's the default, otherwise we add 'blocks-storage.bucket-store.bucket-index.enabled': false, as you did.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand correctly, you wanted the blocks-storage.bucket-store.bucket-index.enabled': true to be deleted. I remember wondering about this when I made the change. Is the intention to never set flags that are defaults to minimize the configuration and let future changes be picked up more easily?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the intention to never set flags that are defaults to minimize the configuration and let future changes be picked up more easily?

Yes, that's the idea, whenever it makes sense. I think in this case it does.

@@ -340,7 +340,7 @@ type BucketIndexConfig struct {
}

func (cfg *BucketIndexConfig) RegisterFlagsWithPrefix(f *flag.FlagSet, prefix string) {
f.BoolVar(&cfg.Enabled, prefix+"enabled", false, "True to enable querier and store-gateway to discover blocks in the storage via bucket index instead of bucket scanning.")
f.BoolVar(&cfg.Enabled, prefix+"enabled", true, "If enabled, a querier/store-gateway can discover blocks by reading a bucket index instead of bucket scanning.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] I just wanna make sure it's not they "can" (as an option) but they only discover blocks this way.

Suggested change
f.BoolVar(&cfg.Enabled, prefix+"enabled", true, "If enabled, a querier/store-gateway can discover blocks by reading a bucket index instead of bucket scanning.")
f.BoolVar(&cfg.Enabled, prefix+"enabled", true, "If enabled, queriers and store-gateways discover blocks by reading a bucket index (created and updated by the compactor) instead of periodically scanning the bucket.")

pkg/storegateway/bucket_stores_test.go Show resolved Hide resolved
CHANGELOG.md Outdated
@@ -256,6 +256,7 @@
* [CHANGE] Alertmanager: `-experimental.alertmanager.enable-api` flag has been renamed to `-alertmanager.enable-api` and is now stable. #913
* [CHANGE] Ingester: changed default value of `-blocks-storage.tsdb.retention-period` from `6h` to `24h`. #966
* [CHANGE] Changed default value of `-querier.query-ingesters-within` and `-blocks-storage.tsdb.close-idle-tsdb-timeout` from `0` to `13h`. #966
* [CHANGE] Changed the default value of `-blocks-storage.bucket-store.bucket-index.enabled` to `true`. #924
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should also mention that this means that running compactor is mandatory with the default configuration, because the bucket index is written by the compactor and if it's missing queries on long-term storage will not work.

@@ -60,7 +60,7 @@

// Enable use of bucket index by querier, ruler and store-gateway.
// Bucket index is generated by compactor from Cortex 1.7, there is no flag required to enable this on compactor.
bucket_index_enabled: false,
bucket_index_enabled: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please mention this change in the CHANGELOG section related to the mixin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't even realize that was a section of the CHANGELOG. Is the following sufficient or should it also mention the compactor requirement?

[CHANGE] Changed the default of `bucket_index_enabled` to `true`. #924

Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to mention the compactor requirement because if you use our jsonnet the compactor is already always running.

CHANGELOG section related to the mixin.

I made a mistake. Not the mixin, but the jsonnet one (they're 2 distinct sections). Mixin is just dashboards + alerts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 swapped to the jsonnet section.

@@ -34,7 +34,7 @@ The `bucket-index.json.gz` contains:

The [compactor](./compactor.md) periodically scans the bucket and uploads an updated bucket index to the storage. The frequency at which the bucket index is updated can be configured via `-compactor.cleanup-interval`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

At the top of this file you can find:

The bucket index usage is optional and can be enabled via -blocks-storage.bucket-store.bucket-index.enabled=true (or its respective YAML config option).

Could you rephrase it to clarify that it's enabled by default, please?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can say something like: bucket index is enabled by default,b ut can be disabled via -blocks-storage.bucket-store.bucket-index.enabled=false (not recommended).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Went with:

The bucket index is enabled by default, but it is optional. It can be disabled via -blocks-storage.bucket-store.bucket-index.enabled=false (or its respective YAML config option). Disabling the bucket index is not recommended.

Copy link
Collaborator

@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.

LGTM (modulo a nit I'm just going to merge)

docs/sources/blocks-storage/bucket-index.md Outdated Show resolved Hide resolved
@@ -434,5 +434,7 @@

// Bucket index is updated by compactor on each cleanup cycle.
'blocks-storage.bucket-store.sync-interval': $._config.compactor_cleanup_interval,
} else {},
} else {
'blocks-storage.bucket-store.bucket-index.enabled': false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the intention to never set flags that are defaults to minimize the configuration and let future changes be picked up more easily?

Yes, that's the idea, whenever it makes sense. I think in this case it does.

@pracucci pracucci merged commit bb843d6 into main Feb 7, 2022
@pracucci pracucci deleted the aasp/enable-bucket-index branch February 7, 2022 09:15
@andyasp
Copy link
Contributor Author

andyasp commented Feb 7, 2022

Thanks for the help with getting this in!

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