From 5af651db24beffa019a0721e3e57b001e2275e21 Mon Sep 17 00:00:00 2001 From: Aaron Gao Date: Wed, 19 Oct 2016 13:37:51 -0700 Subject: [PATCH] fix data race in compact_files_test Summary: fix data race Test Plan: compact_files_test Reviewers: sdong, yiwu, andrewkr Reviewed By: andrewkr Subscribers: andrewkr, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D65259 --- db/compact_files_test.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/compact_files_test.cc b/db/compact_files_test.cc index 8f046d14e..051cca8a4 100644 --- a/db/compact_files_test.cc +++ b/db/compact_files_test.cc @@ -50,7 +50,10 @@ class FlushedFileCollector : public EventListener { } return result; } - void ClearFlushedFiles() { flushed_files_.clear(); } + void ClearFlushedFiles() { + std::lock_guard lock(mutex_); + flushed_files_.clear(); + } private: std::vector flushed_files_;