mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
xl: quickHeal heal bucket only when needed. (#3854)
This improves the startup time significantly for clusters which have lot of buckets. Also fixes a bug where `.minio.sys` is created on disks which do not have `format.json`
This commit is contained in:
parent
6f931d29c4
commit
e49efcb9d9
@ -252,6 +252,7 @@ func (xl xlObjects) ListBucketsHeal() ([]BucketInfo, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return listBuckets, err
|
return listBuckets, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over all buckets
|
// Iterate over all buckets
|
||||||
for _, currBucket := range buckets {
|
for _, currBucket := range buckets {
|
||||||
// Check the status of bucket metadata
|
// Check the status of bucket metadata
|
||||||
@ -275,6 +276,7 @@ func (xl xlObjects) ListBucketsHeal() ([]BucketInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort found buckets
|
// Sort found buckets
|
||||||
sort.Sort(byBucketName(listBuckets))
|
sort.Sort(byBucketName(listBuckets))
|
||||||
return listBuckets, nil
|
return listBuckets, nil
|
||||||
@ -284,27 +286,29 @@ func (xl xlObjects) ListBucketsHeal() ([]BucketInfo, error) {
|
|||||||
// during startup i.e healing of buckets, bucket metadata (policy.json,
|
// during startup i.e healing of buckets, bucket metadata (policy.json,
|
||||||
// notification.xml, listeners.json) etc. Currently this function
|
// notification.xml, listeners.json) etc. Currently this function
|
||||||
// supports quick healing of buckets, bucket metadata.
|
// supports quick healing of buckets, bucket metadata.
|
||||||
//
|
|
||||||
// TODO :-
|
|
||||||
// - add support for healing dangling `uploads.json`.
|
|
||||||
// - add support for healing dangling `xl.json`.
|
|
||||||
func quickHeal(storageDisks []StorageAPI, writeQuorum int, readQuorum int) error {
|
func quickHeal(storageDisks []StorageAPI, writeQuorum int, readQuorum int) error {
|
||||||
// List all bucket names from all disks.
|
// List all bucket name occurrence from all disks.
|
||||||
bucketNames, _, err := listAllBuckets(storageDisks)
|
_, bucketOcc, err := listAllBuckets(storageDisks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// All bucket names and bucket metadata should be healed.
|
|
||||||
for bucketName := range bucketNames {
|
// All bucket names and bucket metadata that should be healed.
|
||||||
// Heal bucket and then proceed to heal bucket metadata.
|
for bucketName, occCount := range bucketOcc {
|
||||||
if err = healBucket(storageDisks, bucketName, writeQuorum); err == nil {
|
// Heal bucket only if healing is needed.
|
||||||
if err = healBucketMetadata(storageDisks, bucketName, readQuorum); err == nil {
|
if occCount != len(storageDisks) {
|
||||||
continue
|
// Heal bucket and then proceed to heal bucket metadata if any.
|
||||||
|
if err = healBucket(storageDisks, bucketName, writeQuorum); err == nil {
|
||||||
|
if err = healBucketMetadata(storageDisks, bucketName, readQuorum); err == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Success.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ func newXLObjects(storageDisks []StorageAPI) (ObjectLayer, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize meta volume, if volume already exists ignores it.
|
// Initialize meta volume, if volume already exists ignores it.
|
||||||
if err = initMetaVolume(storageDisks); err != nil {
|
if err = initMetaVolume(xl.storageDisks); err != nil {
|
||||||
return nil, fmt.Errorf("Unable to initialize '.minio.sys' meta volume, %s", err)
|
return nil, fmt.Errorf("Unable to initialize '.minio.sys' meta volume, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user