Skip to content

Commit 70fd549

Browse files
chore: introduce restore_max_concurrency, OS exit when stuck in downloading multipart object (#42)
1 parent e4639e5 commit 70fd549

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

utils/config/defaults.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ var max_concurrency = Default{
7979
mandatory: false,
8080
validationType: CONFIG_RANGE}
8181

82+
var recover_max_concurrency = Default{
83+
key: "recover_max_concurrency",
84+
section: SECTION_BACKINT,
85+
defaultValue: "0",
86+
mandatory: false,
87+
validationType: CONFIG_INT}
88+
8289
var multipart_chunksize = Default{
8390
key: "multipart_chunksize",
8491
section: SECTION_BACKINT,
@@ -164,6 +171,7 @@ var configDefaults = []Default{
164171
endpoint_url,
165172
ibm_auth_endpoint,
166173
max_concurrency,
174+
recover_max_concurrency,
167175
multipart_chunksize,
168176
remove_key_prefix,
169177
additional_key_prefix,

utils/config/getter.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@ func (b BackintConfigT) ObjectLockRetentionPeriod() string {
147147
return b.Get("object_lock_retention_period")
148148
}
149149

150+
/*
151+
Getting the max concurrency for recovery
152+
If set to 0, we take the value from max_concurrency
153+
*/
154+
func (b BackintConfigT) RecoverMaxConcurrency() int {
155+
rmc := global.ToInteger(b.Get("recover_max_concurrency"))
156+
if rmc == 0 {
157+
return global.ToInteger(b.Get("max_concurrency"))
158+
}
159+
return rmc
160+
}
161+
150162
/*
151163
Getting the region
152164
*/

utils/cos/download.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func Download(s3Client *s3.S3, element CosObject) Result {
6262
downloadPartsResults := make(chan DownloadPartResult, numParts)
6363

6464
// Make sure that not more than the maximum number run concurrently
65-
sem := make(chan struct{}, config.BackintConfig.MaxConcurrency())
65+
sem := make(chan struct{}, config.BackintConfig.RecoverMaxConcurrency())
6666

6767
// Map containing the parts which are already downloaded
6868
// but could not yet be written to pipe.
@@ -71,10 +71,10 @@ func Download(s3Client *s3.S3, element CosObject) Result {
7171
partsNotYetWritten := make(ByteMap)
7272

7373
// Downloading parts asynchronously
74-
// (limited by value of maxConcurrency)
74+
// (limited by value of RecoverMaxConcurrency)
7575
for _, downloadPart := range downloadParts {
7676
wgGetObject.Add(1)
77-
sem <- struct{}{} // block if maxConcurrency reached
77+
sem <- struct{}{} // block if RecoverMaxConcurrency reached
7878

7979
downloadSingle := DownloadSingePart{
8080
fifo: fifo,

utils/cos/tools.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ func writeDataToPipe(fifo *os.File, data []byte, nextIndex *int64, pipeBufferSiz
252252
fifo.Name(),
253253
errors.New("Timeout")),
254254
)
255-
return false
255+
global.Logger.Fatal("Stopping execution immediately.")
256+
os.Exit(1)
257+
// return false
256258
case err := <-written:
257259
if err != nil {
258260
global.Logger.Error(fmt.Sprintf(

0 commit comments

Comments
 (0)