mirror of https://github.com/minio/minio.git
error out by default beyond 10000 versions per object (#17803)
``` You've exceeded the limit on the number of versions you can create on this object ```
This commit is contained in:
parent
e0329cfdbb
commit
cb089dcb52
|
@ -190,6 +190,7 @@ const (
|
|||
ErrMaximumExpires
|
||||
ErrSlowDownRead
|
||||
ErrSlowDownWrite
|
||||
ErrMaxVersionsExceeded
|
||||
ErrInvalidPrefixMarker
|
||||
ErrBadRequest
|
||||
ErrKeyTooLongError
|
||||
|
@ -857,6 +858,11 @@ var errorCodes = errorCodeMap{
|
|||
Description: "Resource requested is unwritable, please reduce your request rate",
|
||||
HTTPStatusCode: http.StatusServiceUnavailable,
|
||||
},
|
||||
ErrMaxVersionsExceeded: {
|
||||
Code: "MaxVersionsExceeded",
|
||||
Description: "You've exceeded the limit on the number of versions you can create on this object",
|
||||
HTTPStatusCode: http.StatusBadRequest,
|
||||
},
|
||||
ErrInvalidPrefixMarker: {
|
||||
Code: "InvalidPrefixMarker",
|
||||
Description: "Invalid marker prefix combination",
|
||||
|
@ -2110,6 +2116,8 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) {
|
|||
apiErr = ErrSlowDownRead
|
||||
case errErasureWriteQuorum:
|
||||
apiErr = ErrSlowDownWrite
|
||||
case errMaxVersionsExceeded:
|
||||
apiErr = ErrMaxVersionsExceeded
|
||||
// SSE errors
|
||||
case errInvalidEncryptionParameters:
|
||||
apiErr = ErrInvalidEncryptionParameters
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2015-2021 MinIO, Inc.
|
||||
// Copyright (c) 2015-2023 MinIO, Inc.
|
||||
//
|
||||
// This file is part of MinIO Object Storage stack
|
||||
//
|
||||
|
@ -24,6 +24,9 @@ import (
|
|||
"github.com/minio/minio/internal/logger"
|
||||
)
|
||||
|
||||
// errMaxVersionsExceeded return error beyond 10000 (default) versions per object
|
||||
var errMaxVersionsExceeded = StorageErr("maximum versions exceeded, please delete few versions to proceed")
|
||||
|
||||
// errUnexpected - unexpected error, requires manual intervention.
|
||||
var errUnexpected = StorageErr("unexpected error, please report this issue at https://github.com/minio/minio/issues")
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -37,9 +38,31 @@ import (
|
|||
"github.com/minio/minio/internal/bucket/replication"
|
||||
xhttp "github.com/minio/minio/internal/http"
|
||||
"github.com/minio/minio/internal/logger"
|
||||
"github.com/minio/pkg/env"
|
||||
"github.com/tinylib/msgp/msgp"
|
||||
)
|
||||
|
||||
// Reject creating new versions when a single object is cross maxObjectVersions
|
||||
var maxObjectVersions = 10000
|
||||
|
||||
func init() {
|
||||
v := env.Get("_MINIO_OBJECT_MAX_VERSIONS", "")
|
||||
if v != "" {
|
||||
maxv, err := strconv.Atoi(v)
|
||||
if err != nil {
|
||||
logger.Info("invalid _MINIO_OBJECT_MAX_VERSIONS value: %s, defaulting to '10000'", v)
|
||||
maxObjectVersions = 10000
|
||||
} else {
|
||||
if maxv < 10 {
|
||||
logger.Info("invalid _MINIO_OBJECT_MAX_VERSIONS value: %s, minimum allowed is '10' defaulting to '10000'", v)
|
||||
maxObjectVersions = 10000
|
||||
} else {
|
||||
maxObjectVersions = maxv
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
// XL header specifies the format
|
||||
xlHeader = [4]byte{'X', 'L', '2', ' '}
|
||||
|
@ -1070,6 +1093,12 @@ func (x *xlMetaV2) addVersion(ver xlMetaV2Version) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// returns error if we have exceeded maxObjectVersions
|
||||
if len(x.versions)+1 > maxObjectVersions {
|
||||
return errMaxVersionsExceeded
|
||||
}
|
||||
|
||||
// Add space at the end.
|
||||
// Will have -1 modtime, so it will be inserted there.
|
||||
x.versions = append(x.versions, xlMetaV2ShallowVersion{header: xlMetaV2VersionHeader{ModTime: -1}})
|
||||
|
|
|
@ -2211,6 +2211,7 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
|
|||
errFileVersionNotFound,
|
||||
errDiskNotFound,
|
||||
errUnformattedDisk,
|
||||
errMaxVersionsExceeded,
|
||||
}
|
||||
if err != nil && !IsErr(err, ignoredErrs...) && !contextCanceled(ctx) {
|
||||
// Only log these errors if context is not yet canceled.
|
||||
|
|
|
@ -18,7 +18,7 @@ For optimal production setup MinIO recommends Linux kernel version 4.x and later
|
|||
## Limits of S3 API
|
||||
|
||||
| Item | Specification |
|
||||
|:--------------------------------------------------------------------------------|:------------------------------------------------|
|
||||
|:--------------------------------------------------------------------------------|:--------------------------------------------------------------------------------|
|
||||
| Maximum number of buckets | unlimited (we recommend not beyond 500000 buckets) |
|
||||
| Maximum number of objects per bucket | no-limit |
|
||||
| Maximum object size | 50 TiB |
|
||||
|
@ -32,6 +32,7 @@ For optimal production setup MinIO recommends Linux kernel version 4.x and later
|
|||
| Maximum length for bucket names | 63 |
|
||||
| Maximum length for object names | 1024 |
|
||||
| Maximum length for '/' separated object name segment | 255 |
|
||||
| Maximum number of versions per object | 10000 (can be configured to higher values but we do not recommend beyond 10000) |
|
||||
|
||||
## List of Amazon S3 API's not supported on MinIO
|
||||
|
||||
|
|
Loading…
Reference in New Issue