diff --git a/trace_replay/block_cache_tracer.cc b/trace_replay/block_cache_tracer.cc index 4c5ad0116..b163216d8 100644 --- a/trace_replay/block_cache_tracer.cc +++ b/trace_replay/block_cache_tracer.cc @@ -233,7 +233,7 @@ Status BlockCacheTracer::StartTrace( std::unique_ptr&& trace_writer) { InstrumentedMutexLock lock_guard(&trace_writer_mutex_); if (writer_.load()) { - return Status::OK(); + return Status::Busy(); } trace_options_ = trace_options; writer_.store( diff --git a/trace_replay/block_cache_tracer_test.cc b/trace_replay/block_cache_tracer_test.cc index 44cba7bfb..e7a588104 100644 --- a/trace_replay/block_cache_tracer_test.cc +++ b/trace_replay/block_cache_tracer_test.cc @@ -195,6 +195,17 @@ TEST_F(BlockCacheTracerTest, AtomicWrite) { } } +TEST_F(BlockCacheTracerTest, ConsecutiveStartTrace) { + TraceOptions trace_opt; + std::unique_ptr 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(); {