mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
fix: upon write failure on disk journal close the file properly (#18183)
close the file properly before dereferencing *os.File, this can silently leak fd's in rare cases. This PR fixes this properly.
This commit is contained in:
parent
18550387d5
commit
11544a62aa
@ -195,6 +195,10 @@ func (jd *tierDiskJournal) addEntry(je jentry) error {
|
||||
defer jd.Unlock()
|
||||
_, err = jd.file.Write(b)
|
||||
if err != nil {
|
||||
// Do not leak fd here, close the file properly.
|
||||
Fdatasync(jd.file)
|
||||
_ = jd.file.Close()
|
||||
|
||||
jd.file = nil // reset to allow subsequent reopen when file/disk is available.
|
||||
}
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user