Skip to content

Commit 42075e6

Browse files
authored
storage/azblob: Added Minimal Sleep Duration to Avoid Busy Requests (#59636)
ref #59339
1 parent 4db34bc commit 42075e6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

br/pkg/storage/azblob.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const (
4646

4747
azblobPremisedCopySpeedPerSecond = 100 * units.MiB
4848
azblobPremisedCopySpeedPerMilliSecond = azblobPremisedCopySpeedPerSecond / 1000
49+
azblobCopyPollPendingMinimalDuration = 2 * time.Second
4950
)
5051

5152
const azblobRetryTimes int32 = 5
@@ -445,7 +446,12 @@ func (s *AzureBlobStorage) CopyFrom(ctx context.Context, e ExternalStorage, spec
445446
}
446447
rem := total - finished
447448
toSleep := time.Duration(rem/azblobPremisedCopySpeedPerMilliSecond) * time.Millisecond
448-
logutil.CL(ctx).Info("AzureBlobStorage: asyncrhonous copy triggered",
449+
// In practice, most copies finish when the initial request returns.
450+
// To avoid a busy loop of requesting, we need a minimal sleep duration.
451+
if toSleep < azblobCopyPollPendingMinimalDuration {
452+
toSleep = azblobCopyPollPendingMinimalDuration
453+
}
454+
logutil.CL(ctx).Info("AzureBlobStorage: asynchronous copy triggered",
449455
zap.Int("finished", finished), zap.Int("total", total),
450456
zap.Stringp("copy-id", prop.CopyID), zap.Duration("to-sleep", toSleep),
451457
zap.Stringp("copy-desc", prop.CopyStatusDescription),

0 commit comments

Comments
 (0)