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: last-modified of empty shard directory shouldn't be Unix epoch. #21481

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -14,6 +14,7 @@
1. [21375](https://github.com/influxdata/influxdb/pull/21375): Add logging to NATS streaming server to help debug startup failures.
1. [21477](https://github.com/influxdata/influxdb/pull/21477): Accept `--input` instead of a positional arg in `influx restore`.
1. [21477](https://github.com/influxdata/influxdb/pull/21477): Print error instead of panicking when `influx restore` fails to find backup manifests.
1. [21481](https://github.com/influxdata/influxdb/pull/21481): Set last-modified time of empty shard directory to the directory's mod time instead of Unix epoch.

## v2.0.6 [2021-04-29]

Expand Down
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()
} 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