@ -698,8 +698,7 @@ class StressTest {
}
}
if ( ! FLAGS_test_batches_snapshots ) {
if ( ! FLAGS_test_batches_snapshots ) {
thread - > shared - > GetStressTest ( ) - > VerifyDb ( * ( thread - > shared ) ,
thread - > shared - > GetStressTest ( ) - > VerifyDb ( thread ) ;
thread - > tid ) ;
}
}
{
{
@ -1064,15 +1063,18 @@ class StressTest {
thread - > stats . Stop ( ) ;
thread - > stats . Stop ( ) ;
}
}
void VerifyDb ( const SharedState & shared , long ti d) const {
void VerifyDb ( ThreadState * threa d) const {
ReadOptions options ( FLAGS_verify_checksum , true ) ;
ReadOptions options ( FLAGS_verify_checksum , true ) ;
long max_key = shared . GetMaxKey ( ) ;
const SharedState & shared = * ( thread - > shared ) ;
static const long max_key = shared . GetMaxKey ( ) ;
static const long keys_per_thread = max_key / shared . GetNumThreads ( ) ;
static const long keys_per_thread = max_key / shared . GetNumThreads ( ) ;
long start = keys_per_thread * tid ;
long start = keys_per_thread * thread - > tid ;
long end = start + keys_per_thread ;
long end = start + keys_per_thread ;
if ( tid = = shared . GetNumThreads ( ) - 1 ) {
if ( thread - > tid = = shared . GetNumThreads ( ) - 1 ) {
end = max_key ;
end = max_key ;
}
}
if ( ! thread - > rand . OneIn ( 2 ) ) {
// Use iterator to verify this range
unique_ptr < Iterator > iter ( db_ - > NewIterator ( options ) ) ;
unique_ptr < Iterator > iter ( db_ - > NewIterator ( options ) ) ;
iter - > Seek ( Key ( start ) ) ;
iter - > Seek ( Key ( start ) ) ;
for ( long i = start ; i < end ; i + + ) {
for ( long i = start ; i < end ; i + + ) {
@ -1100,6 +1102,20 @@ class StressTest {
}
}
}
}
}
}
else {
// Use Get to verify this range
for ( long i = start ; i < end ; i + + ) {
std : : string from_db ;
std : : string keystr = Key ( i ) ;
Slice k = keystr ;
Status s = db_ - > Get ( options , k , & from_db ) ;
VerifyValue ( i , options , shared , from_db , s , true ) ;
if ( from_db . length ( ) ) {
PrintKeyValue ( i , from_db . data ( ) , from_db . length ( ) ) ;
}
}
}
}
void VerificationAbort ( std : : string msg , long key ) const {
void VerificationAbort ( std : : string msg , long key ) const {
fprintf ( stderr , " Verification failed for key %ld: %s \n " ,
fprintf ( stderr , " Verification failed for key %ld: %s \n " ,