anchor.diff:                                        compactor_pid=undefined,
                                         compactor_fun=Fun} = State) ->
       true = [] =/= Buckets,
  -
  -    NextBucket = hd(Buckets),
  -
  -    {InitialConfig, _ConfigProps} = Configs = compaction_config(NextBucket),
  -
  -    Compactor = Fun(NextBucket, Configs),
  +    compact_bucket(hd(Buckets), Fun, State).
  +
  +-spec compact_bucket(binary(), fun(), #compaction_state{}) -> #compaction_state{}.
  +compact_bucket(BucketName, Fun, State) ->
  +    {InitialConfig, _ConfigProps} = Configs = compaction_config(BucketName),
  +
  +    Compactor = Fun(BucketName, Configs),
       State#compaction_state{compactor_pid = Compactor,
                              compactor_config = InitialConfig}.
  +
  +-spec compact_views_for_paused_bucket(binary(), #compaction_state{}) -> #compaction_state{}.
  +compact_views_for_paused_bucket(BucketName, State) ->
  +    compact_bucket(BucketName,
  +                   fun spawn_views_compactor_for_paused_bucket/2,
  +                   State#compaction_state{buckets_to_compact = [BucketName]}).
   
   db_name(BucketName, SubName) when is_list(SubName) ->
       db_name(BucketName, list_to_binary(SubName));
  
positive.code:       fun () ->
                check_period_and_maybe_exit(Config),
                exit_if_no_bucket(BucketName),
  
                try_to_cleanup_indexes(BucketName),
  
  
negative.code: handle_info(compact_views, #state{views_compaction=CompactionState} = State) ->
      {noreply, State#state{views_compaction=
                                process_scheduler_message(CompactionState)}};
  handle_info({'DOWN', MRef, _, _, _}, #state{view_compaction_inhibited_ref=MRef,
                                              view_compaction_inhibited_bucket=BinBucket}=State) ->
      ?log_debug("Looks like vbucket mover inhibiting view compaction for for bucket \"~s\" is dead."
                 " Canceling inhibition", [BinBucket]),
      {noreply, State#state{view_compaction_inhibited_ref = undefined,
                            view_compaction_inhibited_bucket = undefined}};
  handle_info({'EXIT', Compactor, Reason},
              #state{kv_compaction=#compaction_state{compactor_pid=Compactor}=
                         CompactorState} = State) ->
      log_compactors_exit(Reason, CompactorState),
      {noreply, State#state{kv_compaction=
                                process_compactors_exit(Reason, CompactorState)}};
  handle_info({'EXIT', Compactor, Reason},
              #state{views_compaction=#compaction_state{compactor_pid = Compactor,
                                                        buckets_to_compact = Buckets} =
                         CompactorState} = State) ->
      log_compactors_exit(Reason, CompactorState),
  
      NewState = case (Buckets =:= [State#state.view_compaction_inhibited_bucket]
                       andalso State#state.view_compaction_uninhibit_started) of
                     true ->
                         gen_server:reply(State#state.view_compaction_uninhibit_requested_waiter, ok),
                         State#state{view_compaction_inhibited_bucket = undefined,
                                     view_compaction_uninhibit_requested_waiter = undefined,
                                     view_compaction_uninhibit_requested = false,
                                     view_compaction_uninhibit_started = false};
                     _ ->
                         State
                 end,
  
      case NewState#state.view_compaction_uninhibit_requested andalso
          not NewState#state.view_compaction_uninhibit_started of
          true ->
              {noreply,
               NewState#state{view_compaction_uninhibit_started = true,
                              views_compaction =
                                  compact_views_for_paused_bucket(
                                    NewState#state.view_compaction_inhibited_bucket,
                                    CompactorState)}};
          false ->
              {noreply, NewState#state{views_compaction=
                                           process_compactors_exit(Reason, CompactorState)}}
      end;
  handle_info({'EXIT', Pid, Reason},
              #state{running_forced_compactions=Compactions} = State) ->
      case dict:find(Pid, Compactions) of
  