@@ -321,7 +321,7 @@ void CompactionJob::AcquireSubcompactionResources(
321
321
->write_controller ()
322
322
->NeedSpeedupCompaction ())
323
323
.max_compactions ;
324
- db_mutex_-> Lock ( );
324
+ InstrumentedMutexLock l (db_mutex_ );
325
325
// Apply min function first since We need to compute the extra subcompaction
326
326
// against compaction limits. And then try to reserve threads for extra
327
327
// subcompactions. The actual number of reserved threads could be less than
@@ -346,7 +346,6 @@ void CompactionJob::AcquireSubcompactionResources(
346
346
} else {
347
347
*bg_compaction_scheduled_ += extra_num_subcompaction_threads_reserved_;
348
348
}
349
- db_mutex_->Unlock ();
350
349
}
351
350
352
351
void CompactionJob::ShrinkSubcompactionResources (uint64_t num_extra_resources) {
@@ -380,19 +379,20 @@ void CompactionJob::ReleaseSubcompactionResources() {
380
379
if (extra_num_subcompaction_threads_reserved_ == 0 ) {
381
380
return ;
382
381
}
383
- db_mutex_->Lock ();
384
- // The number of reserved threads becomes larger than 0 only if the
385
- // compaction prioity is round robin and there is no sufficient
386
- // sub-compactions available
387
-
388
- // The scheduled compaction must be no less than 1 + extra number
389
- // subcompactions using acquired resources since this compaction job has not
390
- // finished yet
391
- assert (*bg_bottom_compaction_scheduled_ >=
392
- 1 + extra_num_subcompaction_threads_reserved_ ||
393
- *bg_compaction_scheduled_ >=
394
- 1 + extra_num_subcompaction_threads_reserved_);
395
- db_mutex_->Unlock ();
382
+ {
383
+ InstrumentedMutexLock l (db_mutex_);
384
+ // The number of reserved threads becomes larger than 0 only if the
385
+ // compaction prioity is round robin and there is no sufficient
386
+ // sub-compactions available
387
+
388
+ // The scheduled compaction must be no less than 1 + extra number
389
+ // subcompactions using acquired resources since this compaction job has not
390
+ // finished yet
391
+ assert (*bg_bottom_compaction_scheduled_ >=
392
+ 1 + extra_num_subcompaction_threads_reserved_ ||
393
+ *bg_compaction_scheduled_ >=
394
+ 1 + extra_num_subcompaction_threads_reserved_);
395
+ }
396
396
ShrinkSubcompactionResources (extra_num_subcompaction_threads_reserved_);
397
397
}
398
398
0 commit comments