From 991bb28797568fee037dbaf5a1b467d1e54b0ac3 Mon Sep 17 00:00:00 2001 From: Wallace Date: Tue, 28 Apr 2020 19:07:35 +0800 Subject: [PATCH] Fix life time of `memtable_write_group` (#171) * fix life time of memtable_write_group Signed-off-by: Little-Wallace --- .travis.yml | 2 ++ db/db_impl/db_impl_write.cc | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 62b9fd22a5a..992bf48acd6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/db/db_impl/db_impl_write.cc b/db/db_impl/db_impl_write.cc index b690fc0fad5..0c0210aca90 100644 --- a/db/db_impl/db_impl_write.cc +++ b/db/db_impl/db_impl_write.cc @@ -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) { @@ -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);