88import time
99
1010import progressbar
11+ # This actually imports progressbar2 but `import progressbar2' itself doesn't work.
12+ # In case of problems with the progressbar/progressbar2, check that you have the
13+ # progressbar2 installed and the path to it or venv is specified.
14+
1115import psycopg2 .extensions
1216
1317import common
@@ -55,13 +59,13 @@ def run_tpcds(config):
5559 TPC_DS_STATEMENT_TIMEOUT = 20000 # statement_timeout in ms
5660
5761 print ('Preparing TPC-DS queries...' )
62+ err_count = 0
5863 queries = []
5964 for query_file in sorted (os .listdir ('tmp_stress/tpcds-result-reproduction/query_qualification/' )):
6065 with open ('tmp_stress/tpcds-result-reproduction/query_qualification/%s' % query_file , 'r' ) as f :
6166 queries .append (f .read ())
6267
6368 acon , = common .n_async_connect (config )
64- pid = acon .get_backend_pid ()
6569
6670 print ('Starting TPC-DS queries...' )
6771 timeout_list = []
@@ -84,8 +88,25 @@ def run_tpcds(config):
8488 PG_QS_DELAY , BEFORE_GETTING_QS_DELAY = 0.1 , 0.1
8589 BEFORE_GETTING_QS , GETTING_QS = range (2 )
8690 state , n_first_getting_qs_retries = BEFORE_GETTING_QS , 0
91+
92+ pg_qs_args = {
93+ 'config' : config ,
94+ 'pid' : acon .get_backend_pid ()
95+ }
96+
8797 while True :
88- result , notices = common .pg_query_state (config , pid )
98+ try :
99+ result , notices = common .pg_query_state (** pg_qs_args )
100+ except Exception as e :
101+ # do not consider the test failed if the "error in message
102+ # queue data transmitting" is received, this may happen with
103+ # some small probability, but if it happens too often it is
104+ # a problem, we will handle this case after the loop
105+ if "error in message queue data transmitting" in e .pgerror :
106+ err_count += 1
107+ else :
108+ raise e
109+
89110 # run state machine to determine the first getting of query state
90111 # and query finishing
91112 if state == BEFORE_GETTING_QS :
@@ -109,6 +130,12 @@ def run_tpcds(config):
109130 except psycopg2 .extensions .QueryCanceledError :
110131 timeout_list .append (i + 1 )
111132
133+ if err_count > 2 :
134+ print ("ERROR: error in message queue data transmitting" )
135+ raise
136+ elif err_count > 0 :
137+ print (err_count , " times there was error in message queue data transmitting" )
138+
112139 common .n_close ((acon ,))
113140
114141 if len (timeout_list ) > 0 :
0 commit comments