Skip to content

Fix issue where chainSampleIterator can obscure errors - #13006

Merged
bwplotka merged 2 commits into
prometheus:mainfrom
charleskorn:chainsampleiterator-errors
Oct 31, 2023
Merged

Fix issue where chainSampleIterator can obscure errors#13006
bwplotka merged 2 commits into
prometheus:mainfrom
charleskorn:chainsampleiterator-errors

Conversation

@charleskorn

Copy link
Copy Markdown
Contributor

If any iterator in a chainSampleIterator has a sample after the desired timestamp when Seek() is called, Seek() will not return ValNone.

If some iterators have failed (ie. calling innerIterator.Err() returns a non-nil value) and others have not, this behaviour may hide errors from those iterators: callers of Seek() will not receive ValNone and therefore won't know to check chainSampleIterator.Err().

Next() is susceptible to a similar issue if Next() is not called until the stream is completely exhausted.

This PR upstreams the change from grafana/mimir-prometheus#540, which has already been tested in Mimir.

Signed-off-by: Charles Korn <charles.korn@grafana.com>

@bwplotka bwplotka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! LGTM, just a few readability nits if you don't mind (killing else - my life mission 🙈 )

Rationales: https://thanos.io/tip/contributing/coding-style-guide.md/#control-structure-prefer-early-returns-and-avoid-else

Comment thread storage/merge.go Outdated
Comment thread storage/merge.go Outdated
Signed-off-by: Charles Korn <charles.korn@grafana.com>
@charleskorn
charleskorn requested a review from bwplotka October 26, 2023 05:08
@charleskorn

Copy link
Copy Markdown
Contributor Author

@bwplotka any chance you could take another look at this? I've addressed your feedback.

@bwplotka bwplotka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Epic, thanks!

@bwplotka
bwplotka merged commit 5184368 into prometheus:main Oct 31, 2023
@charleskorn
charleskorn deleted the chainsampleiterator-errors branch November 22, 2023 06:22
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.

2 participants