mirror of
https://github.com/prometheus/prometheus
synced 2024-12-25 07:52:28 +00:00
tsdb: sync temporary checkpoint directory before rename (#7004)
Signed-off-by: zhulongcheng <zhulongcheng.dev@gmail.com>
This commit is contained in:
parent
51306cb158
commit
5ea6bdca1f
@ -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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user