@@ -441,6 +441,9 @@ func (c *Client) httpPost(_path string, payload []byte) (body []byte, statusCode
441
441
func (c * Client ) getChunk (offset int64 ) (* types.TransactionChunk , error ) {
442
442
_path := "chunk/" + strconv .FormatInt (offset , 10 )
443
443
body , statusCode , err := c .httpGet (_path )
444
+ if statusCode == 429 {
445
+ return nil , ErrRequestLimit
446
+ }
444
447
if statusCode != 200 {
445
448
return nil , errors .New ("not found chunk data" )
446
449
}
@@ -551,14 +554,16 @@ func (c *Client) ConcurrentDownloadChunkData(id string, concurrentNum int) ([]by
551
554
chunkData , err := c .getChunkData (oss .Offset )
552
555
if err != nil {
553
556
count := 0
554
- for count < 50 {
557
+ for count < 3 {
555
558
time .Sleep (2 * time .Second )
556
559
chunkData , err = c .getChunkData (oss .Offset )
557
560
if err == nil {
558
561
break
559
562
}
560
- log .Error ("retry getChunkData failed and try again..." , "err" , err , "offset" , oss .Offset , "retryCount" , count )
561
- count ++
563
+ log .Error ("retry getChunkData failed and try again..." , "err" , err , "offset" , oss .Offset , "retryCount" , count , "arId" , id )
564
+ if err != ErrRequestLimit {
565
+ count ++
566
+ }
562
567
}
563
568
}
564
569
lock .Lock ()
@@ -583,14 +588,16 @@ func (c *Client) ConcurrentDownloadChunkData(id string, concurrentNum int) ([]by
583
588
chunkData , err := c .getChunkData (int64 (i ) + start )
584
589
if err != nil {
585
590
count := 0
586
- for count < 50 {
591
+ for count < 3 {
587
592
time .Sleep (2 * time .Second )
588
593
chunkData , err = c .getChunkData (int64 (i ) + start )
589
594
if err == nil {
590
595
break
591
596
}
592
- log .Error ("retry getChunkData failed and try again..." , "err" , err , "offset" , int64 (i )+ start , "retryCount" , count )
593
- count ++
597
+ log .Error ("retry getChunkData failed and try again..." , "err" , err , "offset" , int64 (i )+ start , "retryCount" , count , "arId" , id )
598
+ if err != ErrRequestLimit {
599
+ count ++
600
+ }
594
601
}
595
602
}
596
603
chunkArr = append (chunkArr , chunkData )
0 commit comments