From 21441c09bdd5df9201a999b9e56b747d02607683 Mon Sep 17 00:00:00 2001 From: Islam AbdelRahman Date: Fri, 29 Apr 2016 17:00:50 -0700 Subject: [PATCH] Fix calling GetCurrentMutableCFOptions in CompactionJob::ProcessKeyValueCompaction() Summary: GetCurrentMutableCFOptions() can only be called when DB mutex is held so we cannot call it in CompactionJob::ProcessKeyValueCompaction() since it's not holding the db mutex Test Plan: make check -j64 Reviewers: sdong, andrewkr Reviewed By: andrewkr Subscribers: andrewkr, dhruba Differential Revision: https://reviews.facebook.net/D57471 --- db/column_family.h | 2 +- db/compaction_job.cc | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/db/column_family.h b/db/column_family.h index 1a4036e60..f0dbced85 100644 --- a/db/column_family.h +++ b/db/column_family.h @@ -209,7 +209,7 @@ class ColumnFamilyData { const ImmutableCFOptions* ioptions() const { return &ioptions_; } // REQUIRES: DB mutex held // This returns the MutableCFOptions used by current SuperVersion - // You shoul use this API to reference MutableCFOptions most of the time. + // You should use this API to reference MutableCFOptions most of the time. const MutableCFOptions* GetCurrentMutableCFOptions() const { return &(super_version_->mutable_cf_options); } diff --git a/db/compaction_job.cc b/db/compaction_job.cc index 90f155869..c4eb3a12a 100644 --- a/db/compaction_job.cc +++ b/db/compaction_job.cc @@ -669,6 +669,8 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) { } ColumnFamilyData* cfd = sub_compact->compaction->column_family_data(); + const MutableCFOptions* mutable_cf_options = + sub_compact->compaction->mutable_cf_options(); // To build compression dictionary, we sample the first output file, assuming // it'll reach the maximum length, and then use the dictionary for compressing @@ -680,9 +682,8 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) { cfd->ioptions()->compression_opts.max_dict_bytes > 0) { const size_t kMaxSamples = cfd->ioptions()->compression_opts.max_dict_bytes >> kSampleLenShift; - const size_t kOutFileLen = - cfd->GetCurrentMutableCFOptions()->MaxFileSizeForLevel( - compact_->compaction->output_level()); + const size_t kOutFileLen = mutable_cf_options->MaxFileSizeForLevel( + compact_->compaction->output_level()); if (kOutFileLen != port::kMaxSizet) { const size_t kOutFileNumSamples = kOutFileLen >> kSampleLenShift; Random64 generator{versions_->NewFileNumber()};