Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5876bfd

Browse files
committed
More predictable reconnects in test; also squeeze common error messages into one
1 parentfaf90ea commit5876bfd

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

‎tests2/lib/bank_client.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
importaioprocessing
1212
importmultiprocessing
1313
importlogging
14+
importre
1415

1516
classMtmTxAggregate(object):
1617

@@ -26,16 +27,19 @@ def clear_values(self):
2627
defstart_tx(self):
2728
self.start_time=datetime.datetime.now()
2829

29-
deffinish_tx(self,name):
30+
deffinish_tx(self,status):
3031
latency= (datetime.datetime.now()-self.start_time).total_seconds()
3132

33+
if"is aborted on node"instatus:
34+
status=re.sub(r'MTM-.+\)','<censored>',status)
35+
3236
iflatency>self.max_latency:
3337
self.max_latency=latency
3438

35-
ifnamenotinself.finish:
36-
self.finish[name]=1
39+
ifstatusnotinself.finish:
40+
self.finish[status]=1
3741
else:
38-
self.finish[name]+=1
42+
self.finish[status]+=1
3943

4044
defas_dict(self):
4145
return {
@@ -62,6 +66,7 @@ def __init__(self, dsns, n_accounts=100000):
6266
# logging.basicConfig(level=logging.DEBUG)
6367
self.n_accounts=n_accounts
6468
self.dsns=dsns
69+
self.total=0
6570
self.aggregates= {}
6671
keep_trying(40,1,self.initdb,'self.initdb')
6772
self.running=True
@@ -176,11 +181,11 @@ def exec_tx(self, tx_block, aggname_prefix, conn_i):
176181
# enable_hstore tries to perform select from database
177182
# which in case of select's failure will lead to exception
178183
# and stale connection to the database
179-
conn=yieldfromaiopg.connect(dsn,enable_hstore=False,timeout=3600)
180-
print("reconnected")
184+
conn=yieldfromaiopg.connect(dsn,enable_hstore=False,timeout=1)
185+
print('Connected %s, %d'% (aggname_prefix,conn_i+1))
181186

182187
if (notcur)orcur.closed:
183-
cur=yieldfromconn.cursor()
188+
cur=yieldfromconn.cursor(timeout=10)
184189

185190
# ROLLBACK tx after previous exception.
186191
# Doing this here instead of except handler to stay inside try
@@ -198,17 +203,17 @@ def exec_tx(self, tx_block, aggname_prefix, conn_i):
198203
# Give evloop some free time.
199204
# In case of continuous excetions we can loop here without returning
200205
# back to event loop and block it
201-
if"Multimaster node is not online"inmsg:
202-
yieldfromasyncio.sleep(1.00)
203-
else:
204-
yieldfromasyncio.sleep(0.01)
206+
yieldfromasyncio.sleep(0.5)
207+
205208
exceptBaseExceptionase:
206-
print('Catch exception ',type(e))
207-
agg.finish_tx(str(e).strip())
209+
msg=str(e).strip()
210+
agg.finish_tx(msg)
211+
print('Caught exception %s, %s, %d, %s'% (type(e),aggname_prefix,conn_i+1,msg) )
212+
208213
# Give evloop some free time.
209214
# In case of continuous excetions we can loop here without returning
210215
# back to event loop and block it
211-
yieldfromasyncio.sleep(0.01)
216+
yieldfromasyncio.sleep(0.5)
212217

213218
print("We've count to infinity!")
214219

@@ -235,10 +240,11 @@ def transfer_tx(self, conn, cur, agg):
235240
deftotal_tx(self,conn,cur,agg):
236241
yieldfromcur.execute('select sum(amount) from bank_test')
237242
total=yieldfromcur.fetchone()
238-
iftotal[0]!=0:
243+
iftotal[0]!=self.total:
239244
agg.isolation+=1
240-
# print(self.oops)s
241-
# print('Isolation error, total = ', total[0])
245+
self.total=total[0]
246+
print(self.oops)
247+
print('Isolation error, total = ',total[0])
242248
# yield from cur.execute('select * from mtm.get_nodes_state()')
243249
# nodes_state = yield from cur.fetchall()
244250
# for i, col in enumerate(self.nodes_state_fields):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp