Skip to content

Commit

Permalink
fix: last-modified of empty shard directory shouldn't be Unix epoch. (#…
Browse files Browse the repository at this point in the history
…21481)



Co-authored-by: davidby-influx <[email protected]>
  • Loading branch information
danxmoran and davidby-influx authored May 17, 2021
1 parent cc4ebe2 commit fc3beb7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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

0 comments on commit fc3beb7

Please sign in to comment.