File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88import logging
99import json
1010import time
11+ from random import uniform
1112from datetime import datetime
1213
13- from dbs .apis .dbsClient import DbsApi
14+ from dbs .apis .dbsClient import DbsApi as DbsApiBase
1415from dbs .exceptions .dbsClientException import dbsClientException
1516from RestClient .ErrorHandling .RestClientExceptions import HTTPError
1617
1718from TaskWorker .WorkerExceptions import CannotMigrateException
1819
20+ MAX_RETRY_ATTEMPTS = 3
21+ MIN_RETRY_DELAY = 10
22+ MAX_RETRY_DELAY = 3 * 60 # 3 minutes
23+
24+ logger = logging .getLogger (__name__ )
25+
26+ class DbsApi (DbsApiBase ):
27+
28+ def insertBulkBlock (self , block_dump ):
29+ retry_count = 0
30+ last_ex = None
31+ while retry_count < MAX_RETRY_ATTEMPTS :
32+ try :
33+ return super ().insertBulkBlock (block_dump )
34+ except HTTPError as ex :
35+ last_ex = ex
36+ body = json .loads (ex .body )
37+ reason = body [0 ]['error' ]['reason' ]
38+ if ex .code == 400 and 'ORA-00001' in reason :
39+ block_name = block_dump ['block' ]['block_name' ]
40+ logger .info (f"Retry { retry_count + 1 } of { MAX_RETRY_ATTEMPTS } for inserting bulk block { block_name } " )
41+ time .sleep (uniform (MIN_RETRY_DELAY , MAX_RETRY_DELAY ))
42+ retry_count += 1
43+ continue
44+ raise
45+ raise Exception (f"Error inserting bulk block: { last_ex } after { MAX_RETRY_ATTEMPTS } attempts" ) from last_ex
1946
2047def format_file_3 (file_ ):
2148 """
You can’t perform that action at this time.
0 commit comments