add configurable delta for skipping shards (#13967)

This PR is an attempt to make this configurable
as not all situations have same level of tolerable
delta, i.e disks are replaced days apart or even
hours.

There is also a possibility that nodes have drifted
in time, when NTP is not configured on the system.
This commit is contained in:
Harshavardhana 2021-12-22 11:43:01 -08:00 committed by GitHub
parent ebd78e983f
commit 54ec0a1308
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 9 deletions

View File

@ -29,6 +29,7 @@ function start_minio_16drive() {
export MINIO_ROOT_PASSWORD=minio123 export MINIO_ROOT_PASSWORD=minio123
export MC_HOST_minio="http://minio:minio123@127.0.0.1:${start_port}/" export MC_HOST_minio="http://minio:minio123@127.0.0.1:${start_port}/"
unset MINIO_KMS_AUTO_ENCRYPTION # do not auto-encrypt objects unset MINIO_KMS_AUTO_ENCRYPTION # do not auto-encrypt objects
export _MINIO_SHARD_DISKTIME_DELTA="5s" # do not change this as its needed for tests
MC_BUILD_DIR="mc-$RANDOM" MC_BUILD_DIR="mc-$RANDOM"
if ! git clone --quiet https://github.com/minio/mc "$MC_BUILD_DIR"; then if ! git clone --quiet https://github.com/minio/mc "$MC_BUILD_DIR"; then

View File

@ -86,7 +86,20 @@ func (s1 ServerSystemConfig) Diff(s2 ServerSystemConfig) error {
} }
} }
if !reflect.DeepEqual(s1.MinioEnv, s2.MinioEnv) { if !reflect.DeepEqual(s1.MinioEnv, s2.MinioEnv) {
return fmt.Errorf("Expected same MINIO_ environment variables and values") var missing []string
var mismatching []string
for k, v := range s1.MinioEnv {
ev, ok := s2.MinioEnv[k]
if !ok {
missing = append(missing, k)
} else if v != ev {
mismatching = append(mismatching, k)
}
}
if len(mismatching) > 0 {
return fmt.Errorf(`Expected same MINIO_ environment variables and values across all servers: Missing environment values: %s / Mismatch environment values: %s`, missing, mismatching)
}
return fmt.Errorf(`Expected same MINIO_ environment variables and values across all servers: Missing environment values: %s`, missing)
} }
return nil return nil
} }
@ -94,6 +107,7 @@ func (s1 ServerSystemConfig) Diff(s2 ServerSystemConfig) error {
var skipEnvs = map[string]struct{}{ var skipEnvs = map[string]struct{}{
"MINIO_OPTS": {}, "MINIO_OPTS": {},
"MINIO_CERT_PASSWD": {}, "MINIO_CERT_PASSWD": {},
"MINIO_SERVER_DEBUG": {},
} }
func getServerSystemCfg() ServerSystemConfig { func getServerSystemCfg() ServerSystemConfig {

View File

@ -67,6 +67,7 @@ import (
// serverDebugLog will enable debug printing // serverDebugLog will enable debug printing
var serverDebugLog = env.Get("_MINIO_SERVER_DEBUG", config.EnableOff) == config.EnableOn var serverDebugLog = env.Get("_MINIO_SERVER_DEBUG", config.EnableOff) == config.EnableOn
var shardDiskTimeDelta time.Duration
var defaultAWSCredProvider []credentials.Provider var defaultAWSCredProvider []credentials.Provider
func init() { func init() {
@ -136,6 +137,12 @@ func init() {
}, },
} }
var err error
shardDiskTimeDelta, err = time.ParseDuration(env.Get("_MINIO_SHARD_DISKTIME_DELTA", "1m"))
if err != nil {
shardDiskTimeDelta = 1 * time.Minute
}
// All minio-go API operations shall be performed only once, // All minio-go API operations shall be performed only once,
// another way to look at this is we are turning off retries. // another way to look at this is we are turning off retries.
minio.MaxRetry = 1 minio.MaxRetry = 1

View File

@ -229,7 +229,6 @@ func disksWithAllParts(ctx context.Context, onlineDisks []StorageAPI, partsMetad
bucket, object string, scanMode madmin.HealScanMode) ([]StorageAPI, []error) { bucket, object string, scanMode madmin.HealScanMode) ([]StorageAPI, []error) {
var diskMTime time.Time var diskMTime time.Time
delta := 5 * time.Second
if !latestMeta.DataShardFixed() { if !latestMeta.DataShardFixed() {
diskMTime = pickValidDiskTimeWithQuorum(partsMetadata, diskMTime = pickValidDiskTimeWithQuorum(partsMetadata,
latestMeta.Erasure.DataBlocks) latestMeta.Erasure.DataBlocks)
@ -340,7 +339,7 @@ func disksWithAllParts(ctx context.Context, onlineDisks []StorageAPI, partsMetad
} }
if !diskMTime.Equal(timeSentinel) && !diskMTime.IsZero() { if !diskMTime.Equal(timeSentinel) && !diskMTime.IsZero() {
if !partsMetadata[i].AcceptableDelta(diskMTime, delta) { if !partsMetadata[i].AcceptableDelta(diskMTime, shardDiskTimeDelta) {
// not with in acceptable delta, skip. // not with in acceptable delta, skip.
partsMetadata[i] = FileInfo{} partsMetadata[i] = FileInfo{}
continue continue

View File

@ -354,7 +354,7 @@ func findFileInfoInQuorum(ctx context.Context, metaArr []FileInfo, modTime time.
func pickValidDiskTimeWithQuorum(metaArr []FileInfo, quorum int) time.Time { func pickValidDiskTimeWithQuorum(metaArr []FileInfo, quorum int) time.Time {
diskMTimes := listObjectDiskMtimes(metaArr) diskMTimes := listObjectDiskMtimes(metaArr)
diskMTime, diskMaxima := commonTimeAndOccurence(diskMTimes, 5*time.Second) diskMTime, diskMaxima := commonTimeAndOccurence(diskMTimes, shardDiskTimeDelta)
if diskMaxima >= quorum { if diskMaxima >= quorum {
return diskMTime return diskMTime
} }

View File

@ -28,7 +28,6 @@ import (
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"time"
"github.com/minio/madmin-go" "github.com/minio/madmin-go"
"github.com/minio/minio-go/v7/pkg/tags" "github.com/minio/minio-go/v7/pkg/tags"
@ -182,7 +181,6 @@ func (er erasureObjects) GetObjectNInfo(ctx context.Context, bucket, object stri
if !fi.DataShardFixed() { if !fi.DataShardFixed() {
diskMTime := pickValidDiskTimeWithQuorum(metaArr, fi.Erasure.DataBlocks) diskMTime := pickValidDiskTimeWithQuorum(metaArr, fi.Erasure.DataBlocks)
delta := 5 * time.Second
if !diskMTime.Equal(timeSentinel) && !diskMTime.IsZero() { if !diskMTime.Equal(timeSentinel) && !diskMTime.IsZero() {
for index := range onlineDisks { for index := range onlineDisks {
if onlineDisks[index] == OfflineDisk { if onlineDisks[index] == OfflineDisk {
@ -191,7 +189,7 @@ func (er erasureObjects) GetObjectNInfo(ctx context.Context, bucket, object stri
if !metaArr[index].IsValid() { if !metaArr[index].IsValid() {
continue continue
} }
if !metaArr[index].AcceptableDelta(diskMTime, delta) { if !metaArr[index].AcceptableDelta(diskMTime, shardDiskTimeDelta) {
// If disk mTime mismatches it is considered outdated // If disk mTime mismatches it is considered outdated
// https://github.com/minio/minio/pull/13803 // https://github.com/minio/minio/pull/13803
// //