Skip to content

Commit

Permalink
Fix SIGABRT caused by uninitialized mutex (#296) (#298)
Browse files Browse the repository at this point in the history
* Fix SIGABRT caused by uninitialized mutex

Signed-off-by: Wenbo Zhang <[email protected]>

* Use spinlock instead of mutex to reduce writer ctor cost

Signed-off-by: Wenbo Zhang <[email protected]>

* Update db/write_thread.h

Co-authored-by: Xinye Tao <[email protected]>
Signed-off-by: Wenbo Zhang <[email protected]>

Co-authored-by: Xinye Tao <[email protected]>
Signed-off-by: Wenbo Zhang <[email protected]>

Co-authored-by: Xinye Tao <[email protected]>
  • Loading branch information
ethercflow and tabokie authored Jul 7, 2022
1 parent 32f8f2b commit 9bb7147
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion db/write_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ void WriteThread::Writer::ConsumeOne(size_t claimed) {
multi_batch.ignore_missing_column_families, 0, this->log_ref,
multi_batch.db, true);
if (!s.ok()) {
std::lock_guard<std::mutex> guard(this->StateMutex());
std::lock_guard<SpinMutex> guard(this->status_lock);
this->status = s;
}
multi_batch.pending_wb_cnt.fetch_sub(1, std::memory_order_acq_rel);
Expand Down
4 changes: 3 additions & 1 deletion db/write_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "rocksdb/types.h"
#include "rocksdb/write_batch.h"
#include "util/autovector.h"
#include "util/mutexlock.h"

namespace ROCKSDB_NAMESPACE {

Expand Down Expand Up @@ -190,7 +191,8 @@ class WriteThread {
WriteGroup* write_group;
CommitRequest* request;
SequenceNumber sequence; // the sequence number to use for the first key
Status status;
Status status; // write protected by status_lock in multi batch write.
SpinMutex status_lock;
Status callback_status; // status returned by callback->Callback()

std::aligned_storage<sizeof(std::mutex)>::type state_mutex_bytes;
Expand Down

0 comments on commit 9bb7147

Please sign in to comment.