anchor.diff:              exit({open_db_failed, Error})
       end.
   
  -spawn_vbucket_compactor(BucketName, {_, DbName} = VBucketAndDb, Options) ->
  +vbucket_needs_compaction({DataSize, FileSize}, Config) ->
  +    #config{daemon=#daemon_config{min_file_size=MinFileSize},
  +            db_fragmentation=FragThreshold} = Config,
  +
  +    file_needs_compaction(DataSize, FileSize, FragThreshold, MinFileSize).
  +
  +spawn_vbucket_compactor(BucketName, {_, DbName} = VBucketAndDb,
  +                        Config, Force, Options) ->
       Parent = self(),
   
       proc_lib:spawn_link(
         fun () ->
                 Db = open_db_or_fail(BucketName, VBucketAndDb),
  +              {ok, DbInfo} = couch_db:get_db_info(Db),
  +              SizeInfo = db_size_info(DbInfo),
  +
  +              case Force orelse vbucket_needs_compaction(SizeInfo, Config) of
  +                  true ->
  +                      ok;
  +                  false ->
  +                      exit(normal)
  +              end,
   
                 %% effectful
  -              ensure_can_db_compact(Db),
  +              ensure_can_db_compact(Db, SizeInfo),
   
                 ?log_info("Compacting ~p", [DbName]),
   
  
positive.code: 
      {DataSize, FileSize} = aggregated_size_info(SampleVBucketDbs, NumVBuckets),
  
      file_needs_compaction(BucketName,
                            DataSize, FileSize, FragThreshold,
                            MinFileSize * NumVBuckets).
  
  select_samples(VBucketDbs, SampleIxs) ->
      select_samples(VBucketDbs, SampleIxs, 1, []).
  
negative.code:                     FileSize = proplists:get_value(disk_size, Info),
                      DataSize = proplists:get_value(data_size, Info, 0),
  
                      ?log_debug("`~s/~s/~s` data_size is ~p, disk_size is ~p",
                                 [BucketName, DDocId, Type, DataSize, FileSize]),
  
                      file_needs_compaction(DataSize, FileSize,
                                            FragThreshold, MinFileSize)
              end
      end.
  