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

store: add consistency delay to fetch blocks #2009

Merged
merged 1 commit into from Feb 18, 2020

Conversation

khyatisoneji
Copy link
Contributor

Add consistency delay in store component to fetch blocks

@khyatisoneji khyatisoneji force-pushed the store-consistency branch 2 times, most recently from 5a48716 to 9e9e53f Compare January 17, 2020 19:44
@khyatisoneji
Copy link
Contributor Author

Although this is a rough implementation of adding filters in store, I wanted to get feedback on this approach.

I have added two filters:
a. Consistency filter: This is to account for eventual consistency for storing data in external storage
b. Garbage Blocks filter: This is to filter out the blocks that will be deleted by compactor, so these blocks should not be synced by store.

Please let me know if there are any additional filters that I should apply and also if this is in the right direction.
I will add tests and also make the code more structured.

@khyatisoneji khyatisoneji force-pushed the store-consistency branch 2 times, most recently from 8d802d9 to e9ecbd6 Compare January 17, 2020 19:52
Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

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

Some small comments but overall looks good to me! Thanks a lot! Also, it seems like we have another case of flaky CI tests, will rerun it.

cmd/thanos/store.go Outdated Show resolved Hide resolved
cmd/thanos/store.go Outdated Show resolved Hide resolved
cmd/thanos/store.go Outdated Show resolved Hide resolved
@khyatisoneji khyatisoneji force-pushed the store-consistency branch 4 times, most recently from d012a46 to 568595b Compare January 20, 2020 15:50
@khyatisoneji
Copy link
Contributor Author

@GiedriusS the tests are still breaking, can you retrigger them? Also please check if that it because of code changes

Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

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

Yes, your changes are indeed related. It's a good opportunity to try to run the E2E tests on your machine locally and see what's wrong, and update / improve them. In the CircleCI page you can see the debug message block is too fresh for now being printed by Thanos Store which means that it has filtered some blocks which hasn't occurred before and hence most likely Thanos Query cannot find which StoreAPI nodes to query. This is because Thanos Store announces all of the label sets that it finds - you can see that in the /stores page.

pkg/block/fetcher.go Outdated Show resolved Hide resolved
cmd/thanos/store.go Outdated Show resolved Hide resolved
@khyatisoneji khyatisoneji force-pushed the store-consistency branch 5 times, most recently from 3c68464 to 53230ac Compare January 24, 2020 18:49
pkg/testutil/prometheus.go Outdated Show resolved Hide resolved
pkg/compact/compact_e2e_test.go Outdated Show resolved Hide resolved
test/e2e/store_gateway_test.go Outdated Show resolved Hide resolved
@khyatisoneji khyatisoneji force-pushed the store-consistency branch 2 times, most recently from 1a57ad2 to 1faaec1 Compare January 24, 2020 19:20
@khyatisoneji
Copy link
Contributor Author

The TestStoreGateway test has been failing.

The reason is that in this test, we are creating the block by calling tsdb LeveledCompactor's Write function.
In this function, it creates the folder using ulid.Now(), but here we want to use ulid.Now() - consistencyDelay as the folder to write to, since we want to use the default value of consistencyDelay in the test.

Is there anyway in which I can provide the id of the block to write to tsdb? Otherwise we have to use consistencyDelay as 0.

@yeya24
Copy link
Contributor

yeya24 commented Jan 24, 2020

The TestStoreGateway test has been failing.

The reason is that in this test, we are creating the block by calling tsdb LeveledCompactor's Write function.
In this function, it creates the folder using ulid.Now(), but here we want to use ulid.Now() - consistencyDelay as the folder to write to, since we want to use the default value of consistencyDelay in the test.

Is there anyway in which I can provide the id of the block to write to tsdb? Otherwise we have to use consistencyDelay as 0.

AFAIK, there is no way to customize block id when you want to create a block in TSDB using the existing API

@khyatisoneji
Copy link
Contributor Author

What would be an alternate way to test a block id that was created consistencyDelay time ago?

Our default value of consistencyDelay is 30m, so we want to only fetch the blocks which are older than 30m. If we use consistencyDelay as 30m, then the call to fetch blocks fails saying that the block is too fresh.
We cannot also mock the NewConsistencyDelayMetaFilter function.

Is there a way to test the retrieval of blocks that are old?

@khyatisoneji khyatisoneji force-pushed the store-consistency branch 5 times, most recently from b63cb1d to 3409c5b Compare January 29, 2020 17:10
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Hi!

It's looking good, but I think we are trying to do same thing 3 times here:

  • duplicate block filter
  • garbage finder filter
  • garbage finer in compactor loop

Can we have... one way of dealing with duplicate/garbage blocks? ;p

cmd/thanos/store.go Outdated Show resolved Hide resolved
cmd/thanos/compact.go Show resolved Hide resolved
pkg/block/fetcher.go Show resolved Hide resolved
pkg/compact/garbagecollector/garbage_collector.go Outdated Show resolved Hide resolved
pkg/compact/garbagecollector/garbage_collector.go Outdated Show resolved Hide resolved
pkg/testutil/e2eutil/prometheus.go Outdated Show resolved Hide resolved
pkg/testutil/e2eutil/prometheus.go Show resolved Hide resolved
cmd/thanos/store.go Outdated Show resolved Hide resolved
pkg/compact/compact.go Outdated Show resolved Hide resolved
@khyatisoneji khyatisoneji force-pushed the store-consistency branch 4 times, most recently from f41be37 to 5fd6f5f Compare February 13, 2020 10:46
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Awesome!!! Looking super nice, some last suggestions I think 👍

pkg/block/fetcher.go Outdated Show resolved Hide resolved
pkg/block/fetcher.go Outdated Show resolved Hide resolved
pkg/compact/compact.go Outdated Show resolved Hide resolved
pkg/testutil/e2eutil/prometheus.go Show resolved Hide resolved
test/e2e/store_gateway_test.go Show resolved Hide resolved
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Amazing 👍

Good work I love this ❤️

LGTM, just minor nits.

pkg/block/fetcher.go Outdated Show resolved Hide resolved
pkg/block/fetcher.go Outdated Show resolved Hide resolved
pkg/block/fetcher.go Show resolved Hide resolved
pkg/block/fetcher.go Outdated Show resolved Hide resolved
pkg/block/fetcher.go Outdated Show resolved Hide resolved
pkg/block/fetcher.go Show resolved Hide resolved
pkg/block/fetcher_test.go Show resolved Hide resolved
pkg/testutil/e2eutil/prometheus.go Show resolved Hide resolved
pkg/testutil/e2eutil/prometheus.go Show resolved Hide resolved
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thank you!

This looks amazing! Let's merge after rebase and super minor suggestion:muscle:

pkg/block/fetcher.go Show resolved Hide resolved
Signed-off-by: khyatisoneji <khyatisoneji5@gmail.com>
@bwplotka bwplotka merged commit 2e3ece1 into thanos-io:master Feb 18, 2020
@bwplotka
Copy link
Member

👏 👏 👏

vankop pushed a commit to monitoring-tools/thanos that referenced this pull request Feb 28, 2020
Signed-off-by: khyatisoneji <khyatisoneji5@gmail.com>
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.

None yet

4 participants