|
14 | 14 |
|
15 | 15 | fromtimeimportsleep |
16 | 16 |
|
| 17 | +MAX_PG_QS_RETRIES=50 |
| 18 | +TPC_DS_EXCLUDE_LIST= []# actual numbers of TPC-DS tests to exclude |
| 19 | +TPC_DS_STATEMENT_TIMEOUT=20000# statement_timeout in ms |
| 20 | +stress_in_progress=False |
| 21 | + |
17 | 22 | defwait(conn): |
18 | 23 | """wait for some event on connection to postgres""" |
19 | 24 | while1: |
@@ -98,18 +103,21 @@ def pg_query_state(config, pid, verbose=False, costs=False, timing=False, \ |
98 | 103 |
|
99 | 104 | conn=psycopg2.connect(**config) |
100 | 105 | curs=conn.cursor() |
101 | | -set_guc(conn,'statement_timeout',10000) |
| 106 | + |
| 107 | +ifstress_in_progress: |
| 108 | +set_guc(conn,'statement_timeout',TPC_DS_STATEMENT_TIMEOUT) |
| 109 | +n_retries=0 |
102 | 110 |
|
103 | 111 | result= [] |
104 | | -n_retries=0 |
105 | 112 | whilenotresult: |
106 | 113 | curs.callproc('pg_query_state', (pid,verbose,costs,timing,buffers,triggers,format)) |
107 | 114 | result=curs.fetchall() |
108 | | -n_retries+=1 |
109 | 115 |
|
110 | | -ifn_retries==25: |
111 | | -print('pg_query_state tried 25 times with no effect') |
112 | | -break |
| 116 | +ifstress_in_progress: |
| 117 | +n_retries+=1 |
| 118 | +ifn_retries>=MAX_PG_QS_RETRIES: |
| 119 | +print('\npg_query_state tried %s times with no effect, giving up'%MAX_PG_QS_RETRIES) |
| 120 | +break |
113 | 121 |
|
114 | 122 | notices=conn.notices[:] |
115 | 123 | conn.close() |
@@ -565,24 +573,22 @@ def stress_test(config): |
565 | 573 |
|
566 | 574 | acon,=n_async_connect(config) |
567 | 575 |
|
568 | | -print('Startingtest...') |
| 576 | +print('StartingTPC-DS queries...') |
569 | 577 | timeout_list= [] |
570 | | -exclude_list= [] |
571 | 578 | bar=progressbar.ProgressBar(max_value=len(queries)) |
572 | 579 | fori,queryinenumerate(queries): |
573 | 580 | bar.update(i+1) |
574 | | -ifi+1inexclude_list: |
| 581 | +ifi+1inTPC_DS_EXCLUDE_LIST: |
575 | 582 | continue |
576 | 583 | try: |
577 | | -# Set query timeout to10 sec |
578 | | -set_guc(acon,'statement_timeout',10000) |
| 584 | +# Set query timeout toTPC_DS_STATEMENT_TIMEOUT / 1000 seconds |
| 585 | +set_guc(acon,'statement_timeout',TPC_DS_STATEMENT_TIMEOUT) |
579 | 586 | qs=query_state(config,acon,query) |
580 | 587 |
|
581 | | -#TODO: Put here testgres exception when supported |
582 | 588 | exceptpsycopg2.extensions.QueryCanceledError: |
583 | | -timeout_list.append(i) |
| 589 | +timeout_list.append(i+1) |
584 | 590 |
|
585 | 591 | n_close((acon,)) |
586 | 592 |
|
587 | 593 | iflen(timeout_list)>0: |
588 | | -print('There were pg_query_state timeouts (10s) on queries: ',timeout_list) |
| 594 | +print('There were pg_query_state timeouts (%s s) on queries:'%TPC_DS_STATEMENT_TIMEOUT,timeout_list) |