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)
122123for (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" );
125129int lt =0 ;
126130int gt =0 ;
127131while (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" );
135139int delta =0 ;
140+ assert ((int )r1.size () == cfg.nAccounts && (int )r2.size () == cfg.nAccounts );
136141for (int i=0 ; i < cfg.nAccounts ; i++) {
137142int 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 ()));
138147if (diff !=0 ) {
139148if (delta ==0 ) {
140149delta = diff;
141150if (delta <0 ) lt++;else gt++;
142151}else if (delta != diff) {
152+ fflush (out);
143153printf (" 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);
153164printf (" lt=%d, gt=%d\n " , lt, gt);
154165return NULL ;
155166}