diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index 05d688400..387595831 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -411,6 +411,19 @@ void StressTest::VerificationAbort(SharedState* shared, std::string msg, int cf, shared->SetVerificationFailure(); } +void StressTest::VerificationAbort(SharedState* shared, std::string msg, int cf, + int64_t key, Slice value_from_db, + Slice value_from_expected) const { + auto key_str = Key(key); + fprintf(stderr, + "Verification failed for column family %d key %s (%" PRIi64 + "): value_from_db: %s, value_from_expected: %s, msg: %s\n", + cf, Slice(key_str).ToString(true).c_str(), key, + value_from_db.ToString(true).c_str(), + value_from_expected.ToString(true).c_str(), msg.c_str()); + shared->SetVerificationFailure(); +} + void StressTest::PrintStatistics() { if (dbstats) { fprintf(stdout, "STATISTICS:\n%s\n", dbstats->ToString().c_str()); diff --git a/db_stress_tool/db_stress_test_base.h b/db_stress_tool/db_stress_test_base.h index 3a4b8aa57..40e4e7a92 100644 --- a/db_stress_tool/db_stress_test_base.h +++ b/db_stress_tool/db_stress_test_base.h @@ -222,6 +222,10 @@ class StressTest { void VerificationAbort(SharedState* shared, std::string msg, int cf, int64_t key) const; + void VerificationAbort(SharedState* shared, std::string msg, int cf, + int64_t key, Slice value_from_db, + Slice value_from_expected) const; + void PrintEnv() const; void Open(SharedState* shared); diff --git a/db_stress_tool/no_batched_ops_stress.cc b/db_stress_tool/no_batched_ops_stress.cc index 2792cd98a..38ef31f4e 100644 --- a/db_stress_tool/no_batched_ops_stress.cc +++ b/db_stress_tool/no_batched_ops_stress.cc @@ -1264,22 +1264,27 @@ class NonBatchedOpsStressTest : public StressTest { if (s.ok()) { char value[kValueMaxLen]; if (value_base == SharedState::DELETION_SENTINEL) { - VerificationAbort(shared, "Unexpected value found", cf, key); + VerificationAbort(shared, "Unexpected value found", cf, key, + value_from_db, ""); return false; } size_t sz = GenerateValue(value_base, value, sizeof(value)); if (value_from_db.length() != sz) { - VerificationAbort(shared, "Length of value read is not equal", cf, key); + VerificationAbort(shared, "Length of value read is not equal", cf, key, + value_from_db, Slice(value, sz)); return false; } if (memcmp(value_from_db.data(), value, sz) != 0) { - VerificationAbort(shared, "Contents of value read don't match", cf, - key); + VerificationAbort(shared, "Contents of value read don't match", cf, key, + value_from_db, Slice(value, sz)); return false; } } else { if (value_base != SharedState::DELETION_SENTINEL) { - VerificationAbort(shared, "Value not found: " + s.ToString(), cf, key); + char value[kValueMaxLen]; + size_t sz = GenerateValue(value_base, value, sizeof(value)); + VerificationAbort(shared, "Value not found: " + s.ToString(), cf, key, + "", Slice(value, sz)); return false; } }