mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
heal: large objects fix and avoid .healing.bin corner case premature exit (#20577)
xlStorage.Healing() returns nil if there is an error reading .healing.bin or if this latter is empty. healing.bin update() call returns early if .healing.bin is empty; hence, no further update of .healing.bin is possible. A .healing.bin can be empty if os.Open() with O_TRUNC is successful but the next Write returns an error. To avoid this weird situation, avoid making healingTracker.update() to return early if .healing.bin is empty, so write again. This commit also fixes wrong error log printing when an object is healed in another drive in the same erasure set but not in the drive that is actively healing by fresh drive healing code. Currently, it prints <nil> instead of a factual error. * heal: Scan .minio.sys metadata only during site-wide heal (#137) mc admin heal always invoke .minio.sys heal, but sometimes, this latter contains a lot of data, many service accounts, STS accounts etc, which makes mc admin heal command very slow. Only invoke .minio.sys healing when no bucket was specified in `mc admin heal` command.
This commit is contained in:
@@ -432,15 +432,19 @@ func (s *xlStorage) Healing() *healingTracker {
|
||||
bucketMetaPrefix, healingTrackerFilename)
|
||||
b, err := os.ReadFile(healingFile)
|
||||
if err != nil {
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
internalLogIf(GlobalContext, fmt.Errorf("unable to read %s: %w", healingFile, err))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if len(b) == 0 {
|
||||
internalLogIf(GlobalContext, fmt.Errorf("%s is empty", healingFile))
|
||||
// 'healing.bin' might be truncated
|
||||
return nil
|
||||
}
|
||||
h := newHealingTracker()
|
||||
_, err = h.UnmarshalMsg(b)
|
||||
bugLogIf(GlobalContext, err)
|
||||
internalLogIf(GlobalContext, err)
|
||||
return h
|
||||
}
|
||||
|
||||
@@ -2246,6 +2250,7 @@ func (s *xlStorage) writeAllMeta(ctx context.Context, volume string, path string
|
||||
return renameAll(tmpFilePath, filePath, volumeDir)
|
||||
}
|
||||
|
||||
// Create or truncate an existing file before writing
|
||||
func (s *xlStorage) writeAllInternal(ctx context.Context, filePath string, b []byte, sync bool, skipParent string) (err error) {
|
||||
flags := os.O_CREATE | os.O_WRONLY | os.O_TRUNC
|
||||
|
||||
@@ -2268,16 +2273,11 @@ func (s *xlStorage) writeAllInternal(ctx context.Context, filePath string, b []b
|
||||
return err
|
||||
}
|
||||
|
||||
n, err := w.Write(b)
|
||||
_, err = w.Write(b)
|
||||
if err != nil {
|
||||
w.Close()
|
||||
return err
|
||||
}
|
||||
|
||||
if n != len(b) {
|
||||
w.Truncate(0) // to indicate that we did partial write.
|
||||
w.Close()
|
||||
return io.ErrShortWrite
|
||||
return err
|
||||
}
|
||||
|
||||
// Dealing with error returns from close() - 'man 2 close'
|
||||
|
||||
Reference in New Issue
Block a user