Block cache tracer: StartTrace return busy if trace is already started. (#5519)

Summary:
This PR is needed for integration into MyRocks. A second call on StartTrace returns Busy so that MyRocks may return an error to the user.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5519

Test Plan: make clean && USE_CLANG=1 make check -j32

Differential Revision: D16055476

Pulled By: HaoyuHuang

fbshipit-source-id: a51772fb0965c873922757eb470a332b1e02a91d
main
haoyuhuang 6 years ago committed by Facebook Github Bot
parent 10bae8ceb3
commit 68b46a2e36
  1. 2
      trace_replay/block_cache_tracer.cc
  2. 11
      trace_replay/block_cache_tracer_test.cc

@ -233,7 +233,7 @@ Status BlockCacheTracer::StartTrace(
std::unique_ptr<TraceWriter>&& trace_writer) {
InstrumentedMutexLock lock_guard(&trace_writer_mutex_);
if (writer_.load()) {
return Status::OK();
return Status::Busy();
}
trace_options_ = trace_options;
writer_.store(

@ -195,6 +195,17 @@ TEST_F(BlockCacheTracerTest, AtomicWrite) {
}
}
TEST_F(BlockCacheTracerTest, ConsecutiveStartTrace) {
TraceOptions trace_opt;
std::unique_ptr<TraceWriter> trace_writer;
ASSERT_OK(
NewFileTraceWriter(env_, env_options_, trace_file_path_, &trace_writer));
BlockCacheTracer writer;
ASSERT_OK(writer.StartTrace(env_, trace_opt, std::move(trace_writer)));
ASSERT_NOK(writer.StartTrace(env_, trace_opt, std::move(trace_writer)));
ASSERT_OK(env_->FileExists(trace_file_path_));
}
TEST_F(BlockCacheTracerTest, AtomicNoWriteAfterEndTrace) {
BlockCacheTraceRecord record = GenerateAccessRecord();
{

Loading…
Cancel
Save