lib/{mergeset,storage}: properly fsync part directory listing after writing in-memory part to disk

This is a follow-up after 42bba64aa7

Previously the part directory listing was fsync'ed implicitly inside partHeader.WriteMetadata()
by calling fs.WriteFileAtomically(). Now it must be fsync'ed explicitly.

There is no need in fsync'ing the parent directory, since it is fsync'ed by the caller
when updating parts.json file.
This commit is contained in:
Aliaksandr Valialkin 2023-04-13 21:18:39 -07:00
parent 42bba64aa7
commit 25f089de9d
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 4 additions and 6 deletions

View file

@ -56,9 +56,8 @@ func (mp *inmemoryPart) StoreToDisk(path string) error {
if err := mp.ph.WriteMetadata(path); err != nil {
return fmt.Errorf("cannot store metadata: %w", err)
}
// Sync parent directory in order to make sure the written files remain visible after hardware reset
parentDirPath := filepath.Dir(path)
fs.MustSyncPath(parentDirPath)
fs.MustSyncPath(path)
// Do not sync parent directory - it must be synced by the caller.
return nil
}

View file

@ -59,9 +59,8 @@ func (mp *inmemoryPart) StoreToDisk(path string) error {
if err := mp.ph.WriteMetadata(path); err != nil {
return fmt.Errorf("cannot store metadata: %w", err)
}
// Sync parent directory in order to make sure the written files remain visible after hardware reset
parentDirPath := filepath.Dir(path)
fs.MustSyncPath(parentDirPath)
fs.MustSyncPath(path)
// Do not sync parent directory - it must be synced by the caller.
return nil
}