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

fix: Anti-Entropy loops endlessly with empty shard #21275

Merged
merged 1 commit into from
Apr 23, 2021
Merged
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
14 changes: 12 additions & 2 deletions tsdb/engine/tsm1/file_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ func (f *FileStore) Open() error {
}

var lm int64
isEmpty := true
for range files {
res := <-readerC
if res.err != nil {
Expand All @@ -595,9 +596,18 @@ func (f *FileStore) Open() error {
if res.r.LastModified() > lm {
lm = res.r.LastModified()
}

isEmpty = false
}
if isEmpty {
if fi, err := os.Stat(f.dir); err == nil {
f.lastModified = fi.ModTime().UTC()
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it need to account for tombstones? I'm not sure. TSMReader appears to: https://github.com/influxdata/influxdb/blob/master-1.x/tsdb/engine/tsm1/reader.go#L527

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it does account for tombstones. In the loop here, res.r.LastModfied() checks the tombstones, so the directory modification time is only used if the readerC channel is completely empty.

} else {
close(readerC)
return err
}
} else {
f.lastModified = time.Unix(0, lm).UTC()
}
f.lastModified = time.Unix(0, lm).UTC()
close(readerC)

sort.Sort(tsmReaders(f.files))
Expand Down