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
parent
cc4ebe231d
commit
fc3beb7d0a
|
@ -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]
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue