From 4a6840bd004c840112e263cf96c4a21852f03f60 Mon Sep 17 00:00:00 2001 From: Jay Zhuang Date: Tue, 13 Oct 2020 12:37:07 -0700 Subject: [PATCH] db_stress prints key in Hex (#7533) Summary: db_stress prints key in both id and hex. https://github.com/facebook/rocksdb/issues/7531 Pull Request resolved: https://github.com/facebook/rocksdb/pull/7533 Test Plan: local test Reviewed By: akankshamahajan15 Differential Revision: D24252725 Pulled By: jay-zhuang fbshipit-source-id: f0c1409a0568874df36949d5da139316d978fa98 --- db_stress_tool/db_stress_common.cc | 6 ++++-- db_stress_tool/db_stress_test_base.cc | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/db_stress_tool/db_stress_common.cc b/db_stress_tool/db_stress_common.cc index f1823302a..351c28e0c 100644 --- a/db_stress_tool/db_stress_common.cc +++ b/db_stress_tool/db_stress_common.cc @@ -160,8 +160,10 @@ void PrintKeyValue(int cf, uint64_t key, const char* value, size_t sz) { snprintf(buf, 4, "%X", value[i]); tmp.append(buf); } - fprintf(stdout, "[CF %d] %" PRIi64 " == > (%" ROCKSDB_PRIszt ") %s\n", cf, - key, sz, tmp.c_str()); + auto key_str = Key(key); + Slice key_slice = key_str; + fprintf(stdout, "[CF %d] %s (%" PRIi64 ") == > (%" ROCKSDB_PRIszt ") %s\n", + cf, key_slice.ToString(true).c_str(), key, sz, tmp.c_str()); } // Note that if hot_key_alpha != 0, it generates the key based on Zipfian diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index 0df188d5a..fe90a0796 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -329,9 +329,11 @@ void StressTest::VerificationAbort(SharedState* shared, std::string msg, void StressTest::VerificationAbort(SharedState* shared, std::string msg, int cf, int64_t key) const { + auto key_str = Key(key); + Slice key_slice = key_str; fprintf(stderr, - "Verification failed for column family %d key %" PRIi64 ": %s\n", cf, - key, msg.c_str()); + "Verification failed for column family %d key %s (%" PRIi64 "): %s\n", + cf, key_slice.ToString(true).c_str(), key, msg.c_str()); shared->SetVerificationFailure(); }