Skip to content

Commit

Permalink
Merge pull request #212 from JianyuLi/fix-concurrent-raft-create-core
Browse files Browse the repository at this point in the history
fix coredump issue when creating multiple raft groups concurrently in meta merge mode
  • Loading branch information
Edward-xk authored May 26, 2020
2 parents dd81e5b + efa0712 commit eeefc95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/braft/raft_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MetaStorageManager {
typedef butil::DoublyBufferedData<MetaStorageMap> DoublyBufferedMetaStorageMap;

static size_t _add(MetaStorageMap& m, const std::string& path,
const scoped_refptr<KVBasedMergedMetaStorageImpl> mss) {
const scoped_refptr<KVBasedMergedMetaStorageImpl>& mss) {
std::pair<MetaStorageMap::const_iterator, bool> iter =
m.insert(std::make_pair(path, mss));
if (iter.second) {
Expand Down
3 changes: 2 additions & 1 deletion src/braft/raft_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ friend class scoped_refptr<KVBasedMergedMetaStorageImpl>;

public:
explicit KVBasedMergedMetaStorageImpl(const std::string& path)
: _is_inited(false), _path(path) {}
: _is_inited(false), _path(path), _db(nullptr) {}
KVBasedMergedMetaStorageImpl() {}
virtual ~KVBasedMergedMetaStorageImpl() {
if (_db) {
delete _db;
_db = nullptr;
}
}

Expand Down

0 comments on commit eeefc95

Please sign in to comment.