mirror of
https://github.com/minio/minio.git
synced 2025-04-01 02:03:42 -04:00
fix: reduce the load on CPU when loading users/policies (#8984)
Trying to be conservative by slowing ourselves down on a regular basis.
This commit is contained in:
parent
64ec17b463
commit
9ecd66007f
@ -52,6 +52,19 @@ func (h *healRoutine) queueHealTask(task healTask) {
|
|||||||
h.tasks <- task
|
h.tasks <- task
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func waitForLowHTTPReq(tolerance int32) {
|
||||||
|
if httpServer := newHTTPServerFn(); httpServer != nil {
|
||||||
|
// Wait at max 10 minute for an inprogress request before proceeding to heal
|
||||||
|
waitCount := 600
|
||||||
|
// Any requests in progress, delay the heal.
|
||||||
|
for (httpServer.GetRequestCount() >= tolerance) &&
|
||||||
|
waitCount > 0 {
|
||||||
|
waitCount--
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Wait for heal requests and process them
|
// Wait for heal requests and process them
|
||||||
func (h *healRoutine) run() {
|
func (h *healRoutine) run() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@ -62,16 +75,7 @@ func (h *healRoutine) run() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if httpServer := newHTTPServerFn(); httpServer != nil {
|
waitForLowHTTPReq(int32(globalEndpoints.Nodes()))
|
||||||
// Wait at max 10 minute for an inprogress request before proceeding to heal
|
|
||||||
waitCount := 600
|
|
||||||
// Any requests in progress, delay the heal.
|
|
||||||
for (httpServer.GetRequestCount() >= int32(globalEndpoints.Nodes())) &&
|
|
||||||
waitCount > 0 {
|
|
||||||
waitCount--
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var res madmin.HealResultItem
|
var res madmin.HealResultItem
|
||||||
var err error
|
var err error
|
||||||
|
@ -579,6 +579,8 @@ func listIAMConfigItems(objectAPI ObjectLayer, pathPrefix string, dirs bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
defer close(ch)
|
||||||
|
|
||||||
marker := ""
|
marker := ""
|
||||||
for {
|
for {
|
||||||
lo, err := objectAPI.ListObjects(context.Background(),
|
lo, err := objectAPI.ListObjects(context.Background(),
|
||||||
@ -588,9 +590,13 @@ func listIAMConfigItems(objectAPI ObjectLayer, pathPrefix string, dirs bool,
|
|||||||
case ch <- itemOrErr{Err: err}:
|
case ch <- itemOrErr{Err: err}:
|
||||||
case <-doneCh:
|
case <-doneCh:
|
||||||
}
|
}
|
||||||
close(ch)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Slow down listing and loading for config items to
|
||||||
|
// reduce load on the server
|
||||||
|
waitForLowHTTPReq(int32(globalEndpoints.Nodes()))
|
||||||
|
|
||||||
marker = lo.NextMarker
|
marker = lo.NextMarker
|
||||||
lister := dirList(lo)
|
lister := dirList(lo)
|
||||||
if !dirs {
|
if !dirs {
|
||||||
@ -602,12 +608,10 @@ func listIAMConfigItems(objectAPI ObjectLayer, pathPrefix string, dirs bool,
|
|||||||
select {
|
select {
|
||||||
case ch <- itemOrErr{Item: item}:
|
case ch <- itemOrErr{Item: item}:
|
||||||
case <-doneCh:
|
case <-doneCh:
|
||||||
close(ch)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !lo.IsTruncated {
|
if !lo.IsTruncated {
|
||||||
close(ch)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -617,17 +621,17 @@ func listIAMConfigItems(objectAPI ObjectLayer, pathPrefix string, dirs bool,
|
|||||||
|
|
||||||
func (iamOS *IAMObjectStore) watch(sys *IAMSys) {
|
func (iamOS *IAMObjectStore) watch(sys *IAMSys) {
|
||||||
watchDisk := func() {
|
watchDisk := func() {
|
||||||
ticker := time.NewTicker(globalRefreshIAMInterval)
|
|
||||||
defer ticker.Stop()
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-GlobalServiceDoneCh:
|
case <-GlobalServiceDoneCh:
|
||||||
return
|
return
|
||||||
case <-ticker.C:
|
case <-time.NewTimer(globalRefreshIAMInterval).C:
|
||||||
iamOS.loadAll(sys, nil)
|
err := iamOS.loadAll(sys, nil)
|
||||||
|
logger.LogIf(context.Background(), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh IAMSys in background.
|
// Refresh IAMSys in background.
|
||||||
go watchDisk()
|
go watchDisk()
|
||||||
}
|
}
|
||||||
|
@ -1664,16 +1664,7 @@ func (s *xlSets) HealObjects(ctx context.Context, bucket, prefix string, healObj
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if httpServer := newHTTPServerFn(); httpServer != nil {
|
waitForLowHTTPReq(int32(s.drivesPerSet))
|
||||||
// Wait at max 10 minute for an inprogress request before proceeding to heal
|
|
||||||
waitCount := 600
|
|
||||||
// Any requests in progress, delay the heal.
|
|
||||||
for (httpServer.GetRequestCount() >= int32(s.drivesPerSet)) &&
|
|
||||||
waitCount > 0 {
|
|
||||||
waitCount--
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := healObject(bucket, entry.Name); err != nil {
|
if err := healObject(bucket, entry.Name); err != nil {
|
||||||
return toObjectErr(err, bucket, entry.Name)
|
return toObjectErr(err, bucket, entry.Name)
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
|
|
||||||
xhttp "github.com/minio/minio/cmd/http"
|
xhttp "github.com/minio/minio/cmd/http"
|
||||||
"github.com/minio/minio/cmd/logger"
|
"github.com/minio/minio/cmd/logger"
|
||||||
@ -1364,16 +1363,7 @@ func (z *xlZones) HealObjects(ctx context.Context, bucket, prefix string, healOb
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if httpServer := newHTTPServerFn(); httpServer != nil {
|
waitForLowHTTPReq(int32(zoneDrivesPerSet[zoneIndex]))
|
||||||
// Wait at max 10 minute for an inprogress request before proceeding to heal
|
|
||||||
waitCount := 600
|
|
||||||
// Any requests in progress, delay the heal.
|
|
||||||
for (httpServer.GetRequestCount() >= int32(zoneDrivesPerSet[zoneIndex])) &&
|
|
||||||
waitCount > 0 {
|
|
||||||
waitCount--
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := healObject(bucket, entry.Name); err != nil {
|
if err := healObject(bucket, entry.Name); err != nil {
|
||||||
return toObjectErr(err, bucket, entry.Name)
|
return toObjectErr(err, bucket, entry.Name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user