Skip to content

Commit

Permalink
[Bug fix] Cherry-pick bugfix of multi-batch-write to tikv-4.x (#172)
Browse files Browse the repository at this point in the history
* pass enable_multi_thread_write to BuildDBOptions (#170)

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* Fix life time of `memtable_write_group` (#171)

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
  • Loading branch information
Little-Wallace committed Apr 30, 2020
1 parent e61028d commit 765eb91
Show file tree
Hide file tree
Showing 3 changed files with 7 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
1 change: 1 addition & 0 deletions options/options_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ DBOptions BuildDBOptions(const ImmutableDBOptions& immutable_db_options,
options.enable_thread_tracking = immutable_db_options.enable_thread_tracking;
options.delayed_write_rate = mutable_db_options.delayed_write_rate;
options.enable_pipelined_write = immutable_db_options.enable_pipelined_write;
options.enable_multi_thread_write = immutable_db_options.enable_multi_thread_write;
options.unordered_write = immutable_db_options.unordered_write;
options.allow_concurrent_memtable_write =
immutable_db_options.allow_concurrent_memtable_write;
Expand Down

0 comments on commit 765eb91

Please sign in to comment.