2016-08-17 14:36:33 -04:00
|
|
|
/*
|
2019-04-09 14:39:42 -04:00
|
|
|
* MinIO Cloud Storage, (C) 2016 MinIO, Inc.
|
2016-08-17 14:36:33 -04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-08-18 19:23:42 -04:00
|
|
|
package cmd
|
2016-08-17 14:36:33 -04:00
|
|
|
|
2017-09-20 12:50:27 -04:00
|
|
|
import (
|
2018-04-05 18:04:40 -04:00
|
|
|
"context"
|
2018-08-06 18:14:08 -04:00
|
|
|
"io"
|
2017-11-25 14:58:29 -05:00
|
|
|
|
2018-04-05 18:04:40 -04:00
|
|
|
"github.com/minio/minio/cmd/logger"
|
2017-09-20 12:50:27 -04:00
|
|
|
)
|
|
|
|
|
2018-08-24 02:35:37 -04:00
|
|
|
// Heal heals the shard files on non-nil writers. Note that the quorum passed is 1
|
2018-08-06 18:14:08 -04:00
|
|
|
// as healing should continue even if it has been successful healing only one shard file.
|
2019-01-17 07:58:18 -05:00
|
|
|
func (e Erasure) Heal(ctx context.Context, readers []io.ReaderAt, writers []io.Writer, size int64) error {
|
2018-08-06 18:14:08 -04:00
|
|
|
r, w := io.Pipe()
|
|
|
|
go func() {
|
Prefer local disks when fetching data blocks (#9563)
If the requested server is part of the set this will always read
from the local disk, even if the disk contains a parity shard.
In default setup there is a 50% chance that at least
one shard that otherwise would have been fetched remotely
will be read locally instead.
It basically trades RPC call overhead for reed-solomon.
On distributed localhost this seems to be fairly break-even,
with a very small gain in throughput and latency.
However on networked servers this should be a bigger
1MB objects, before:
```
Operation: GET. Concurrency: 32. Hosts: 4.
Requests considered: 76257:
* Avg: 25ms 50%: 24ms 90%: 32ms 99%: 42ms Fastest: 7ms Slowest: 67ms
* First Byte: Average: 23ms, Median: 22ms, Best: 5ms, Worst: 65ms
Throughput:
* Average: 1213.68 MiB/s, 1272.63 obj/s (59.948s, starting 14:45:44 CEST)
```
After:
```
Operation: GET. Concurrency: 32. Hosts: 4.
Requests considered: 78845:
* Avg: 24ms 50%: 24ms 90%: 31ms 99%: 39ms Fastest: 8ms Slowest: 62ms
* First Byte: Average: 22ms, Median: 21ms, Best: 6ms, Worst: 57ms
Throughput:
* Average: 1255.11 MiB/s, 1316.08 obj/s (59.938s, starting 14:43:58 CEST)
```
Bonus fix: Only ask for heal once on an object.
2020-05-26 19:47:23 -04:00
|
|
|
if err := e.Decode(ctx, w, readers, 0, size, size, nil); err != nil {
|
2018-08-06 18:14:08 -04:00
|
|
|
w.CloseWithError(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
w.Close()
|
|
|
|
}()
|
2018-08-24 02:35:37 -04:00
|
|
|
buf := make([]byte, e.blockSize)
|
2018-08-06 18:14:08 -04:00
|
|
|
// quorum is 1 because CreateFile should continue writing as long as we are writing to even 1 disk.
|
2018-08-24 02:35:37 -04:00
|
|
|
n, err := e.Encode(ctx, r, writers, buf, 1)
|
2018-03-04 17:16:45 -05:00
|
|
|
if err != nil {
|
2018-08-06 18:14:08 -04:00
|
|
|
return err
|
2016-08-17 14:36:33 -04:00
|
|
|
}
|
2018-08-06 18:14:08 -04:00
|
|
|
if n != size {
|
|
|
|
logger.LogIf(ctx, errLessData)
|
|
|
|
return errLessData
|
2017-09-28 18:57:19 -04:00
|
|
|
}
|
2018-08-06 18:14:08 -04:00
|
|
|
return nil
|
2017-09-28 18:57:19 -04:00
|
|
|
}
|