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
This commit is contained in:
Zhichao Cao 2020-05-01 00:01:21 -07:00 committed by Facebook GitHub Bot
parent 6acbbbf9fc
commit c8643edfc3

View File

@ -321,6 +321,7 @@ Status Replayer::MultiThreadReplay(uint32_t threads_num) {
if (!s.ok()) { if (!s.ok()) {
break; break;
} }
ra->cf_map = &cf_map_;
ra->woptions = woptions; ra->woptions = woptions;
ra->roptions = roptions; ra->roptions = roptions;
@ -407,6 +408,7 @@ Status Replayer::ReadTrace(Trace* trace) {
void Replayer::BGWorkGet(void* arg) { void Replayer::BGWorkGet(void* arg) {
std::unique_ptr<ReplayerWorkerArg> ra( std::unique_ptr<ReplayerWorkerArg> ra(
reinterpret_cast<ReplayerWorkerArg*>(arg)); reinterpret_cast<ReplayerWorkerArg*>(arg));
assert(ra != nullptr);
auto cf_map = static_cast<std::unordered_map<uint32_t, ColumnFamilyHandle*>*>( auto cf_map = static_cast<std::unordered_map<uint32_t, ColumnFamilyHandle*>*>(
ra->cf_map); ra->cf_map);
uint32_t cf_id = 0; uint32_t cf_id = 0;
@ -429,6 +431,7 @@ void Replayer::BGWorkGet(void* arg) {
void Replayer::BGWorkWriteBatch(void* arg) { void Replayer::BGWorkWriteBatch(void* arg) {
std::unique_ptr<ReplayerWorkerArg> ra( std::unique_ptr<ReplayerWorkerArg> ra(
reinterpret_cast<ReplayerWorkerArg*>(arg)); reinterpret_cast<ReplayerWorkerArg*>(arg));
assert(ra != nullptr);
WriteBatch batch(ra->trace_entry.payload); WriteBatch batch(ra->trace_entry.payload);
ra->db->Write(ra->woptions, &batch); ra->db->Write(ra->woptions, &batch);
return; return;
@ -437,6 +440,7 @@ void Replayer::BGWorkWriteBatch(void* arg) {
void Replayer::BGWorkIterSeek(void* arg) { void Replayer::BGWorkIterSeek(void* arg) {
std::unique_ptr<ReplayerWorkerArg> ra( std::unique_ptr<ReplayerWorkerArg> ra(
reinterpret_cast<ReplayerWorkerArg*>(arg)); reinterpret_cast<ReplayerWorkerArg*>(arg));
assert(ra != nullptr);
auto cf_map = static_cast<std::unordered_map<uint32_t, ColumnFamilyHandle*>*>( auto cf_map = static_cast<std::unordered_map<uint32_t, ColumnFamilyHandle*>*>(
ra->cf_map); ra->cf_map);
uint32_t cf_id = 0; uint32_t cf_id = 0;
@ -461,6 +465,7 @@ void Replayer::BGWorkIterSeek(void* arg) {
void Replayer::BGWorkIterSeekForPrev(void* arg) { void Replayer::BGWorkIterSeekForPrev(void* arg) {
std::unique_ptr<ReplayerWorkerArg> ra( std::unique_ptr<ReplayerWorkerArg> ra(
reinterpret_cast<ReplayerWorkerArg*>(arg)); reinterpret_cast<ReplayerWorkerArg*>(arg));
assert(ra != nullptr);
auto cf_map = static_cast<std::unordered_map<uint32_t, ColumnFamilyHandle*>*>( auto cf_map = static_cast<std::unordered_map<uint32_t, ColumnFamilyHandle*>*>(
ra->cf_map); ra->cf_map);
uint32_t cf_id = 0; uint32_t cf_id = 0;