Skip to content

Commit 1389096

Browse files
FUSAKLAbwplotka
authored andcommitted
fix store: handle invalid cache block dir (#1505)
* fix store: handle invalid cache block dir Signed-off-by: Martin Chodur <m.chodur@seznam.cz> * CR: simplify empty store cache block validation logic Signed-off-by: Martin Chodur <m.chodur@seznam.cz>
1 parent 42e9506 commit 1389096

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ We use *breaking* word for marking changes that are not backward compatible (rel
1111

1212
## Unreleased
1313

14+
### Fixed
15+
16+
-[1505](https://github.com/thanos-io/thanos/pull/1505) Thanos store now removes invalid local cache blocks.
17+
1418
## v0.7.0 - 2019.09.02
1519

1620
Accepted into CNCF:

pkg/store/bucket.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,8 +1188,8 @@ func (b *bucketBlock) indexCacheFilename() string {
11881188
}
11891189

11901190
func loadMeta(ctx context.Context, logger log.Logger, bucket objstore.BucketReader, dir string, id ulid.ULID) (error, *metadata.Meta) {
1191-
// If we haven't seen the block before download the meta.json file.
1192-
if _, err := os.Stat(dir); os.IsNotExist(err) {
1191+
// If we haven't seen the block before or it is missing the meta.json, download it.
1192+
if _, err := os.Stat(path.Join(dir, block.MetaFilename)); os.IsNotExist(err) {
11931193
if err := os.MkdirAll(dir, 0777); err != nil {
11941194
return errors.Wrap(err, "create dir"), nil
11951195
}

0 commit comments

Comments
 (0)