minio/internal/ioutil
Klaus Post b890bbfa63
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.
2022-03-09 11:38:54 -08:00
..
append-file_nix.go run gofumpt cleanup across code-base (#14015) 2022-01-02 09:15:06 -08:00
append-file_windows.go run gofumpt cleanup across code-base (#14015) 2022-01-02 09:15:06 -08:00
ioutil.go Add local disk health checks (#14447) 2022-03-09 11:38:54 -08:00
ioutil_test.go run gofumpt cleanup across code-base (#14015) 2022-01-02 09:15:06 -08:00
odirect_reader.go directio: Check if buffers are set. (#13440) 2021-10-14 10:19:17 -07:00
read_file.go speed up startup sequence for all operations (#14148) 2022-01-24 11:28:45 -08:00
read_file_noatime_notsupported.go fix: enable go1.17 github ci/cd (#12997) 2021-08-18 18:35:22 -07:00
read_file_noatime_supported.go fix: enable go1.17 github ci/cd (#12997) 2021-08-18 18:35:22 -07:00
wait_pipe.go rename all remaining packages to internal/ (#12418) 2021-06-01 14:59:40 -07:00