@@ -51,6 +51,34 @@ def __init__(self, dsns, n_accounts=100000):
5151 self .aggregates = {}
5252 self .initdb ()
5353 self .running = True
54+ self .nodes_state_fields = ["id" , "disabled" , "disconnected" , "catchUp" , "slotLag" ,
55+ "avgTransDelay" , "lastStatusChange" , "oldestSnapshot" , "SenderPid" ,
56+ "SenderStartTime " , "ReceiverPid" , "ReceiverStartTime" , "connStr" ]
57+ self .oops = '''
58+ . . .
59+ \|/
60+ `--+--'
61+ /|\
62+ ' | '
63+ |
64+ |
65+ ,--'#`--.
66+ |#######|
67+ _.-'#######`-._
68+ ,-'###############`-.
69+ ,'#####################`,
70+ /#########################\
71+ |###########################|
72+ |#############################|
73+ |#############################|
74+ |#############################|
75+ |#############################|
76+ |###########################|
77+ \#########################/
78+ `.#####################,'
79+ `._###############_,'
80+ `--..#####..--'
81+ '''
5482
5583 def initdb (self ):
5684 conn = psycopg2 .connect (self .dsns [0 ])
@@ -94,14 +122,14 @@ def exec_tx(self, tx_block, aggname_prefix, conn_i):
94122 agg .start_tx ()
95123 try :
96124 yield from cur .execute ('commit' )
97- yield from tx_block (conn , cur )
125+ yield from tx_block (conn , cur , agg )
98126 agg .finish_tx ('commit' )
99127 except psycopg2 .Error as e :
100128 agg .finish_tx (e .pgerror )
101129 print ("We've count to infinity!" )
102130
103131 @asyncio .coroutine
104- def transfer_tx (self , conn , cur ):
132+ def transfer_tx (self , conn , cur , agg ):
105133 amount = 1
106134 # to avoid deadlocks:
107135 from_uid = random .randint (1 , self .n_accounts - 2 )
@@ -118,12 +146,21 @@ def transfer_tx(self, conn, cur):
118146 yield from cur .execute ('commit' )
119147
120148 @asyncio .coroutine
121- def total_tx (self , conn , cur ):
149+ def total_tx (self , conn , cur , agg ):
122150 yield from cur .execute ('select sum(amount) from bank_test' )
123151 total = yield from cur .fetchone ()
124152 if total [0 ] != 0 :
125- print ('Isolation error, totel = ' , total [0 ])
126- self .isolation += 1
153+ agg .isolation += 1
154+ print (self .oops )
155+ print ('Isolation error, total = ' , total [0 ])
156+ yield from cur .execute ('select * from mtm.get_nodes_state()' )
157+ nodes_state = yield from cur .fetchall ()
158+ for i , col in enumerate (self .nodes_state_fields ):
159+ print ("%17s" % col , end = "\t " )
160+ for j in range (3 ):
161+ print ("%19s" % nodes_state [j ][i ], end = "\t " )
162+ print ("\n " )
163+
127164
128165 def run (self ):
129166 # asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
0 commit comments