mirror of
https://github.com/minio/minio.git
synced 2025-04-20 02:27:50 -04: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()
|
defer jd.Unlock()
|
||||||
_, err = jd.file.Write(b)
|
_, err = jd.file.Write(b)
|
||||||
if err != nil {
|
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.
|
jd.file = nil // reset to allow subsequent reopen when file/disk is available.
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user