From c8643edfc3102dd5eefcaae049ae4a5484301c1d Mon Sep 17 00:00:00 2001 From: Zhichao Cao Date: Fri, 1 May 2020 00:01:21 -0700 Subject: [PATCH] Fix multiple CF replay failure in db_bench replay (#6787) Summary: The multiple CF hash map is not passed to the multi-thread worker. When using multi-thread replay for multiple CFs, it will cause segment fault. Pass the cf_map to the argument. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6787 Test Plan: pass trace replay test. Reviewed By: yhchiang Differential Revision: D21339941 Pulled By: zhichao-cao fbshipit-source-id: 434482b492287e6722c7cd5a706f057c5ec170ce --- trace_replay/trace_replay.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/trace_replay/trace_replay.cc b/trace_replay/trace_replay.cc index a0f9a504f..937c1358f 100644 --- a/trace_replay/trace_replay.cc +++ b/trace_replay/trace_replay.cc @@ -321,6 +321,7 @@ Status Replayer::MultiThreadReplay(uint32_t threads_num) { if (!s.ok()) { break; } + ra->cf_map = &cf_map_; ra->woptions = woptions; ra->roptions = roptions; @@ -407,6 +408,7 @@ Status Replayer::ReadTrace(Trace* trace) { void Replayer::BGWorkGet(void* arg) { std::unique_ptr ra( reinterpret_cast(arg)); + assert(ra != nullptr); auto cf_map = static_cast*>( ra->cf_map); uint32_t cf_id = 0; @@ -429,6 +431,7 @@ void Replayer::BGWorkGet(void* arg) { void Replayer::BGWorkWriteBatch(void* arg) { std::unique_ptr ra( reinterpret_cast(arg)); + assert(ra != nullptr); WriteBatch batch(ra->trace_entry.payload); ra->db->Write(ra->woptions, &batch); return; @@ -437,6 +440,7 @@ void Replayer::BGWorkWriteBatch(void* arg) { void Replayer::BGWorkIterSeek(void* arg) { std::unique_ptr ra( reinterpret_cast(arg)); + assert(ra != nullptr); auto cf_map = static_cast*>( ra->cf_map); uint32_t cf_id = 0; @@ -461,6 +465,7 @@ void Replayer::BGWorkIterSeek(void* arg) { void Replayer::BGWorkIterSeekForPrev(void* arg) { std::unique_ptr ra( reinterpret_cast(arg)); + assert(ra != nullptr); auto cf_map = static_cast*>( ra->cf_map); uint32_t cf_id = 0;