From 9a27ac5d893d588354963f6c4b37fa138343f0b8 Mon Sep 17 00:00:00 2001 From: Yi Wu Date: Mon, 11 Dec 2017 13:46:57 -0800 Subject: [PATCH] Fix drop column family data race Summary: A data race is caught by tsan_crash test between compaction and DropColumnFamily: https://gist.github.com/yiwu-arbug/5a2b4baae05eeb99ae1719b650f30a44 Compaction checks if the column family has been dropped on each key input, while user can issue DropColumnFamily which updates cfd->dropped_, causing the data race. Fixing it by making cfd->dropped_ an atomic. Closes https://github.com/facebook/rocksdb/pull/3250 Differential Revision: D6535991 Pulled By: yiwu-arbug fbshipit-source-id: 5571df020beae7fa7db6fff5ad0d598f49962895 --- db/column_family.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/column_family.h b/db/column_family.h index 2092deed4..9a125aa1c 100644 --- a/db/column_family.h +++ b/db/column_family.h @@ -194,7 +194,7 @@ class ColumnFamilyData { // *) delete all memory associated with that column family // *) delete all the files associated with that column family void SetDropped(); - bool IsDropped() const { return dropped_; } + bool IsDropped() const { return dropped_.load(std::memory_order_relaxed); } // thread-safe int NumberLevels() const { return ioptions_.num_levels; } @@ -358,7 +358,7 @@ class ColumnFamilyData { std::atomic refs_; // outstanding references to ColumnFamilyData std::atomic initialized_; - bool dropped_; // true if client dropped it + std::atomic dropped_; // true if client dropped it const InternalKeyComparator internal_comparator_; std::vector> -- GitLab