fix: last-modified of empty shard directory shouldn't be Unix epoch. (#21481)

Co-authored-by: davidby-influx <72418212+davidby-influx@users.noreply.github.com>
pull/21488/head
Daniel Moran 2021-05-17 13:36:36 -04:00 committed by GitHub
parent cc4ebe231d
commit fc3beb7d0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -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]

View File

@ -576,6 +576,7 @@ func (f *FileStore) Open() error {
}
var lm int64
isEmpty := true
for range files {
res := <-readerC
if res.err != nil {
@ -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))