@@ -51,6 +51,34 @@ def __init__(self, dsns, n_accounts=100000):
51
51
self .aggregates = {}
52
52
self .initdb ()
53
53
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
+ '''
54
82
55
83
def initdb (self ):
56
84
conn = psycopg2 .connect (self .dsns [0 ])
@@ -94,14 +122,14 @@ def exec_tx(self, tx_block, aggname_prefix, conn_i):
94
122
agg .start_tx ()
95
123
try :
96
124
yield from cur .execute ('commit' )
97
- yield from tx_block (conn , cur )
125
+ yield from tx_block (conn , cur , agg )
98
126
agg .finish_tx ('commit' )
99
127
except psycopg2 .Error as e :
100
128
agg .finish_tx (e .pgerror )
101
129
print ("We've count to infinity!" )
102
130
103
131
@asyncio .coroutine
104
- def transfer_tx (self , conn , cur ):
132
+ def transfer_tx (self , conn , cur , agg ):
105
133
amount = 1
106
134
# to avoid deadlocks:
107
135
from_uid = random .randint (1 , self .n_accounts - 2 )
@@ -118,12 +146,21 @@ def transfer_tx(self, conn, cur):
118
146
yield from cur .execute ('commit' )
119
147
120
148
@asyncio .coroutine
121
- def total_tx (self , conn , cur ):
149
+ def total_tx (self , conn , cur , agg ):
122
150
yield from cur .execute ('select sum(amount) from bank_test' )
123
151
total = yield from cur .fetchone ()
124
152
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
+
127
164
128
165
def run (self ):
129
166
# asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
0 commit comments