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

index-shipper: add support for multiple stores #7754

Merged
merged 76 commits into from Apr 14, 2023

Conversation

ashwanthgoli
Copy link
Contributor

@ashwanthgoli ashwanthgoli commented Nov 23, 2022

Signed-off-by: Ashwanth Goli iamashwanth@gmail.com

What this PR does / why we need it:
Currently loki initializes a single instance of index-shipper to handle all the table ranges (from across periods) for a given index type boltdb-shipper, tsdb. Since index-shipper only has the object client handle to the store defined by shared_store_type, it limits the index uploads to a single store. Setting shared_store_type to a different store at a later point in time would mean losing access to the indexes stored in the previously configured store.

With this PR, we initialize a separate index-shipper & table manager for each period if shared_store_type is not explicity configured. This offers the flexibility to store index in multiple stores (across providers).

Note:

  • usage of shared_store_type in this commit text refers to one of these config options depending on the index in use: -boltdb.shipper.shared-store, -tsdb.shipper.shared-store
  • shared_store_type used to default to the object_store from the latest period_config if not explicitly configured. This PR removes these defaults in favor of supporting index uploads to multiple stores.

Which issue(s) this PR fixes:
Fixes #7276

Special notes for your reviewer:
All the instances of downloads table manager operate on the same cacheDir. But it shouldn't be a problem as the tableRanges do not overlap across periods.

Checklist

  • Reviewed the CONTRIBUTING.md guide
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md

Signed-off-by: Ashwanth Goli <iamashwanth@gmail.com>
@github-actions github-actions bot added the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Dec 26, 2022
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

-           ingester	-0.1%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
-            storage	-2.8%
+           chunkenc	0%
+              logql	0%
+               loki	1.2%

@ashwanthgoli ashwanthgoli force-pushed the ashwanth/index-shipper-multi-store branch from a7b32d7 to 054358a Compare December 28, 2022 07:37
@ashwanthgoli ashwanthgoli changed the base branch from main to ashwanth/multi-store-single-provider December 28, 2022 07:38
return nil
}

func (m *HeadManager) buildLegacyWALs() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

lets name it a bit better to make it clearer

Suggested change
func (m *HeadManager) buildLegacyWALs() error {
func (m *HeadManager) buildTSDBFromLegacyWALs() error {

return m.buildWALs(parentDir, true)
}

func (m *HeadManager) buildWALs(dir string, legacy bool) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

lets name it a bit better to make it clearer

Suggested change
func (m *HeadManager) buildWALs(dir string, legacy bool) error {
func (m *HeadManager) buildTSDBFromWALs(dir string, legacy bool) error {

// we do not need to build store for each schema config since we do not do any schema specific handling yet.
// If we do need to do schema specific handling, it would be a good idea to abstract away the handling since
// running multiple head managers would be complicated and wasteful.
// NewStore creates a new tsdb index ReaderWriter.
var NewStore = func() newStoreFactoryFunc {
Copy link
Contributor

Choose a reason for hiding this comment

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

newStoreFactoryFunc was just a hack to make tsdb store instances a singleton. I think we can get rid of it.

@sandeepsukhani
Copy link
Contributor

Great job Ashwanth! The changes look great to me. I think we can merge the PR once we get to test it in a dev cell and ensure things work as expected.

Copy link
Contributor

@sandeepsukhani sandeepsukhani left a comment

Choose a reason for hiding this comment

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

The changes look great and thanks for taking care of all the feedback. Just two minor suggestions, otherwise we are good to merge this.

integration/loki_micro_services_test.go Show resolved Hide resolved
pkg/storage/stores/tsdb/head_manager.go Show resolved Hide resolved
@sandeepsukhani sandeepsukhani merged commit 5cef03d into main Apr 14, 2023
4 checks passed
@sandeepsukhani sandeepsukhani deleted the ashwanth/index-shipper-multi-store branch April 14, 2023 06:02
grafanabot added a commit that referenced this pull request Aug 22, 2023
ashwanthgoli added a commit that referenced this pull request Aug 23, 2023
… multiple stores (#10306)

Add PR #7754 to release notes for next release

---------

Co-authored-by: Ashwanth Goli <iamashwanth@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add-to-release-notes size/XXL type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow for multiple store configurations from the same provider
4 participants