Skip to content

Commit

Permalink
Fix life time of memtable_write_group (#171)
Browse files Browse the repository at this point in the history
* fix life time of memtable_write_group

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
  • Loading branch information
Little-Wallace committed Apr 28, 2020
1 parent 6e7abd5 commit 991bb28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ matrix:
env: TEST_GROUP=3
- os: osx
env: TEST_GROUP=4
- os: osx
env: TEST_GROUP=platform_dependent
- os : linux
compiler: clang
- os: osx
Expand Down
5 changes: 4 additions & 1 deletion db/db_impl/db_impl_write.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ Status DBImpl::MultiBatchWriteImpl(const WriteOptions& write_options,
write_thread_.ExitAsBatchGroupLeader(wal_write_group, writer.status);
}
bool is_leader_thread = false;
WriteThread::WriteGroup memtable_write_group;
if (writer.state == WriteThread::STATE_MEMTABLE_WRITER_LEADER) {
PERF_TIMER_GUARD(write_memtable_time);
assert(writer.ShouldWriteToMemtable());
WriteThread::WriteGroup memtable_write_group;
write_thread_.EnterAsMemTableWriter(&writer, &memtable_write_group);
assert(immutable_db_options_.allow_concurrent_memtable_write);
if (memtable_write_group.size > 1) {
Expand Down Expand Up @@ -215,6 +215,9 @@ Status DBImpl::MultiBatchWriteImpl(const WriteOptions& write_options,
// and it would not notify the threads in this WriteGroup. So we must make someone in
// this WriteGroup to complete it and leader thread is easy to be decided.
if (is_leader_thread) {
if (!write_thread_.CompleteParallelMemTableWriter(&writer)) {
return Status::Aborted("Leader thread must complete at last and exit as memtable writer.");
}
MemTableInsertStatusCheck(writer.status);
versions_->SetLastSequence(writer.write_group->last_sequence);
write_thread_.ExitAsMemTableWriter(&writer, *writer.write_group);
Expand Down

0 comments on commit 991bb28

Please sign in to comment.