Unverified Commit 5ea6bdca by zhulongcheng Committed by GitHub

tsdb: sync temporary checkpoint directory before rename (#7004)

Signed-off-by: 's avatarzhulongcheng <zhulongcheng.dev@gmail.com>
parent 51306cb1
......@@ -249,6 +249,20 @@ func Checkpoint(logger log.Logger, w *WAL, from, to int, keep func(id uint64) bo
if err := cp.Close(); err != nil {
return nil, errors.Wrap(err, "close checkpoint")
}
// Sync temporary directory before rename.
df, err := fileutil.OpenDir(cpdirtmp)
if err != nil {
return nil, errors.Wrap(err, "open temporary checkpoint directory")
}
if err := df.Sync(); err != nil {
df.Close()
return nil, errors.Wrap(err, "sync temporary checkpoint directory")
}
if err = df.Close(); err != nil {
return nil, errors.Wrap(err, "close temporary checkpoint directory")
}
if err := fileutil.Replace(cpdirtmp, cpdir); err != nil {
return nil, errors.Wrap(err, "rename checkpoint directory")
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment