mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
Add local disk health checks (#14447)
The main goal of this PR is to solve the situation where disks stop responding to operations. This generally causes an FD build-up and eventually will crash the server. This adds detection of hung disks, where calls on disk get stuck. We add functionality to `xlStorageDiskIDCheck` where it keeps track of the number of concurrent requests on a given disk. A total number of 100 operations are allowed. If this limit is reached we will block (but not reject) new requests, but we will monitor the state of the disk. If no requests have been completed or updated within a 15-second window, we mark the disk as offline. Requests that are blocked will be unblocked and return an error as "faulty disk". New requests will be rejected until the disk is marked OK again. Once a disk has been marked faulty, a check will run every 5 seconds that will attempt to write and read back a file. As long as this fails the disk will remain faulty. To prevent lots of long-running requests to mark the disk faulty we implement a callback feature that allows updating the status as parts of these operations are running. We add a reader and writer wrapper that will update the status of each successful read/write operation. This should allow fine enough granularity that a slow, but still operational disk will not reach 15 seconds where 50 operations have not progressed. Note that errors themselves are not enough to mark a disk faulty. A nil (or io.EOF) error will mark a disk as "good". * Make concurrent disk setting configurable via `_MINIO_DISK_MAX_CONCURRENT`. * de-couple IsOnline() from disk health tracker The purpose of IsOnline() is to ensure that we reconnect the drive only when the "drive" was - disconnected from network we need to validate if the drive is "correct" and is the same drive which belongs to this server. - drive was replaced we have to format it - we support hot swapping of the drives. IsOnline() is not meant for taking the drive offline when it is hung, it is not useful we can let the drive be online instead "return" errors for relevant calls. * return errFaultyDisk for DiskInfo() call Co-authored-by: Harshavardhana <harsha@minio.io> Possible future Improvements: * Unify the REST server and local xlStorageDiskIDCheck. This would also improve stats significantly. * Allow reads/writes to be aborted by the context. * Add usage stats, concurrent count, blocked operations, etc.
This commit is contained in:
@@ -29,17 +29,40 @@ type StorageAPI interface {
|
||||
String() string
|
||||
|
||||
// Storage operations.
|
||||
IsOnline() bool // Returns true if disk is online.
|
||||
LastConn() time.Time // Returns the last time this disk (re)-connected
|
||||
|
||||
// Returns true if disk is online and its valid i.e valid format.json.
|
||||
// This has nothing to do with if the drive is hung or not responding.
|
||||
// For that individual storage API calls will fail properly. The purpose
|
||||
// of this function is to know if the "drive" has "format.json" or not
|
||||
// if it has a "format.json" then is it correct "format.json" or not.
|
||||
IsOnline() bool
|
||||
|
||||
// Returns the last time this disk (re)-connected
|
||||
LastConn() time.Time
|
||||
|
||||
// Indicates if disk is local or not.
|
||||
IsLocal() bool
|
||||
Hostname() string // Returns host name if remote host.
|
||||
Endpoint() Endpoint // Returns endpoint.
|
||||
|
||||
// Returns hostname if disk is remote.
|
||||
Hostname() string
|
||||
|
||||
// Returns the entire endpoint.
|
||||
Endpoint() Endpoint
|
||||
|
||||
// Close the disk, mark it purposefully closed, only implemented for remote disks.
|
||||
Close() error
|
||||
|
||||
// Returns the unique 'uuid' of this disk.
|
||||
GetDiskID() (string, error)
|
||||
|
||||
// Set a unique 'uuid' for this disk, only used when
|
||||
// disk is replaced and formatted.
|
||||
SetDiskID(id string)
|
||||
Healing() *healingTracker // Returns nil if disk is not healing.
|
||||
|
||||
// Returns healing information for a newly replaced disk,
|
||||
// returns 'nil' once healing is complete or if the disk
|
||||
// has never been replaced.
|
||||
Healing() *healingTracker
|
||||
|
||||
DiskInfo(ctx context.Context) (info DiskInfo, err error)
|
||||
NSScanner(ctx context.Context, cache dataUsageCache, updates chan<- dataUsageEntry) (dataUsageCache, error)
|
||||
|
||||
Reference in New Issue
Block a user