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

.*: Verify if deletion marker file exists before using it. #2369

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel
- [#2254](https://github.com/thanos-io/thanos/pull/2254) Bucket: Fix metrics registered multiple times in bucket replicate
- [#2271](https://github.com/thanos-io/thanos/pull/2271) Bucket Web: Fixed Issue #2260 bucket passes null when storage is empty
- [#2339](https://github.com/thanos-io/thanos/pull/2339) Query: fix a bug where `--store.unhealthy-timeout` was never respected
- [#2369](https://github.com/thanos-io/thanos/pull/2369) .*: verify that deletion marker file exists before reading it. This helps to keep "thanos_objstore_bucket_operation_failures_total" metric low, since missing deletion marker file is not really a failure.

### Added

Expand Down
11 changes: 11 additions & 0 deletions pkg/block/metadata/deletionmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ type DeletionMark struct {
func ReadDeletionMark(ctx context.Context, bkt objstore.BucketReader, logger log.Logger, dir string) (*DeletionMark, error) {
deletionMarkFile := path.Join(dir, DeletionMarkFilename)

// BucketReader.Get reports missing file as a failure (via metrics),
// but since most blocks don't have this marker file, it skews metrics unnecessarily.
// By using exists first, we avoid that.
exists, err := bkt.Exists(ctx, deletionMarkFile)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm dubious about having to do another API call just to check if the object exists, when we can get the same information from Get(). I personally believe #2365 works better (my take here).

Copy link
Member

Choose a reason for hiding this comment

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

ack

if err != nil {
return nil, err
}
if !exists {
return nil, ErrorDeletionMarkNotFound
}

r, err := bkt.Get(ctx, deletionMarkFile)
if err != nil {
if bkt.IsObjNotFoundErr(err) {
Expand Down