1
1
#include < time.h>
2
2
#include < stdio.h>
3
3
#include < stdarg.h>
4
+ #include < assert.h>
4
5
#include < stdlib.h>
5
6
#include < inttypes.h>
6
7
#include < sys/time.h>
@@ -122,6 +123,9 @@ void* reader(void* arg)
122
123
for (size_t i = 0 ; i < conns.size (); i++) {
123
124
conns[i] = new connection (cfg.connections [i]);
124
125
}
126
+ char buf[256 ];
127
+ sprintf (buf, " dump-%d.txt" , t.id );
128
+ FILE* out = fopen (buf, " w" );
125
129
int lt = 0 ;
126
130
int gt = 0 ;
127
131
while (running) {
@@ -133,13 +137,19 @@ void* reader(void* arg)
133
137
result r1 = txn1.exec (" select v,xmin,xmax,mtm.get_csn(xmin),mtm.get_csn(xmax),mtm.get_snapshot(),mtm.get_last_csn() from t order by u" );
134
138
result r2 = txn2.exec (" select v,xmin,xmax,mtm.get_csn(xmin),mtm.get_csn(xmax),mtm.get_snapshot(),mtm.get_last_csn() from t order by u" );
135
139
int delta = 0 ;
140
+ assert ((int )r1.size () == cfg.nAccounts && (int )r2.size () == cfg.nAccounts );
136
141
for (int i=0 ; i < cfg.nAccounts ; i++) {
137
142
int diff = r1[i][0 ].as (int ()) - r2[i][0 ].as (int ());
143
+ fprintf (out, " %d: %d %c %d - [%d,%d]->[%ld,%ld] (snapshot %ld, last CSN %ld) vs. [%d,%d]->[%ld,%ld] (snapshot %ld, last CSN %ld)\n " ,
144
+ i, r1[i][0 ].as (int ()), diff < 0 ? ' <' : diff == 0 ? ' =' : ' >' , r2[i][0 ].as (int ()),
145
+ r1[i][1 ].as (int ()), r1[i][2 ].as (int ()), r1[i][3 ].as (int64_t ()), r1[i][4 ].as (int64_t ()), r1[i][5 ].as (int64_t ()), r1[i][6 ].as (int64_t ()),
146
+ r2[i][1 ].as (int ()), r2[i][2 ].as (int ()), r2[i][3 ].as (int64_t ()), r2[i][4 ].as (int64_t ()), r2[i][5 ].as (int64_t ()), r2[i][6 ].as (int64_t ()));
138
147
if (diff != 0 ) {
139
148
if (delta == 0 ) {
140
149
delta = diff;
141
150
if (delta < 0 ) lt++; else gt++;
142
151
} else if (delta != diff) {
152
+ fflush (out);
143
153
printf (" Inconsistency found for record %d: [%d,%d]->[%ld,%ld] (snapshot %ld, last CSN %ld) vs. [%d,%d]->[%ld,%ld] (snapshot %ld, last CSN %ld)\n " , i,
144
154
r1[i][1 ].as (int ()), r1[i][2 ].as (int ()), r1[i][3 ].as (int64_t ()), r1[i][4 ].as (int64_t ()), r1[i][5 ].as (int64_t ()), r1[i][6 ].as (int64_t ()),
145
155
r2[i][1 ].as (int ()), r2[i][2 ].as (int ()), r2[i][3 ].as (int64_t ()), r2[i][4 ].as (int64_t ()), r2[i][5 ].as (int64_t ()), r2[i][6 ].as (int64_t ()));
@@ -150,6 +160,7 @@ void* reader(void* arg)
150
160
txn1.commit ();
151
161
txn2.commit ();
152
162
}
163
+ fclose (out);
153
164
printf (" lt=%d, gt=%d\n " , lt, gt);
154
165
return NULL ;
155
166
}
0 commit comments