11#include < time.h>
22#include < stdio.h>
33#include < stdarg.h>
4+ #include < assert.h>
45#include < stdlib.h>
56#include < inttypes.h>
67#include < sys/time.h>
@@ -122,6 +123,9 @@ void* reader(void* arg)
122123 for (size_t i = 0 ; i < conns.size (); i++) {
123124 conns[i] = new connection (cfg.connections [i]);
124125 }
126+ char buf[256 ];
127+ sprintf (buf, " dump-%d.txt" , t.id );
128+ FILE* out = fopen (buf, " w" );
125129 int lt = 0 ;
126130 int gt = 0 ;
127131 while (running) {
@@ -133,13 +137,19 @@ void* reader(void* arg)
133137 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" );
134138 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" );
135139 int delta = 0 ;
140+ assert ((int )r1.size () == cfg.nAccounts && (int )r2.size () == cfg.nAccounts );
136141 for (int i=0 ; i < cfg.nAccounts ; i++) {
137142 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 ()));
138147 if (diff != 0 ) {
139148 if (delta == 0 ) {
140149 delta = diff;
141150 if (delta < 0 ) lt++; else gt++;
142151 } else if (delta != diff) {
152+ fflush (out);
143153 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,
144154 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 ()),
145155 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)
150160 txn1.commit ();
151161 txn2.commit ();
152162 }
163+ fclose (out);
153164 printf (" lt=%d, gt=%d\n " , lt, gt);
154165 return NULL ;
155166}
0 commit comments