anchor.diff:                        compactor_config=undefined,
                         compaction_start_ts=undefined,
                         scheduled_compaction_tref=undefined,
  -                      forced_compactors=dict:new()}}.
  +                      running_forced_compactions=dict:new(),
  +                      forced_compaction_pids=dict:new()}}.
   
   handle_event(Event, StateName, State) ->
       ?log_warning("Got unexpected event ~p (when in ~p):~n~p",
                    [Event, StateName, State]),
       {next_state, StateName, State}.
   
  -handle_sync_event({force_compact_bucket, Bucket},
  -                  _From, StateName,
  -                  #state{forced_compactors=Forced} = State) ->
  -    Record = #forced_compaction{type=bucket,
  -                                name=Bucket},
  -    Configs = compaction_config(Bucket),
  -    Pid = spawn_bucket_compactor(Bucket, Configs, true),
  -    NewForced = dict:store(Pid, Record, Forced),
  -    {reply, ok, StateName, State#state{forced_compactors=NewForced}};
  -handle_sync_event({force_compact_db_files, Bucket},
  -                  _From, StateName,
  -                  #state{forced_compactors=Forced} = State) ->
  -    Record = #forced_compaction{type=database,
  -                                name=Bucket},
  -    {Config, _} = compaction_config(Bucket),
  -    Pid = spawn_dbs_compactor(Bucket, Config, true),
  -    NewForced = dict:store(Pid, Record, Forced),
  -    {reply, ok, StateName, State#state{forced_compactors=NewForced}};
  -handle_sync_event({force_compact_view, Bucket, DDocId},
  -                  _From, StateName,
  -                  #state{forced_compactors=Forced} = State) ->
  -    RecordName = <<Bucket/binary, $/, DDocId/binary>>,
  -    Record = #forced_compaction{type=view,
  -                                name=RecordName},
  -    {Config, _} = compaction_config(Bucket),
  -    Pid = spawn_view_compactor(Bucket, DDocId, Config, true),
  -    NewForced = dict:store(Pid, Record, Forced),
  -    {reply, ok, StateName, State#state{forced_compactors=NewForced}};
  +handle_sync_event({force_compact_bucket, Bucket}, _From, StateName, State) ->
  +    Compaction = #forced_compaction{type=bucket, name=Bucket},
  +
  +    NewState =
  +        case is_already_being_compacted(Compaction, State) of
  +            true ->
  +                State;
  +            false ->
  +                Configs = compaction_config(Bucket),
  +                Pid = spawn_bucket_compactor(Bucket, Configs, true),
  +                register_forced_compaction(Pid, Compaction, State)
  +        end,
  +    {reply, ok, StateName, NewState};
  +handle_sync_event({force_compact_db_files, Bucket}, _From, StateName, State) ->
  +    Compaction = #forced_compaction{type=db, name=Bucket},
  +
  +    NewState =
  +        case is_already_being_compacted(Compaction, State) of
  +            true ->
  +                State;
  +            false ->
  +                {Config, _} = compaction_config(Bucket),
  +                Pid = spawn_dbs_compactor(Bucket, Config, true),
  +                register_forced_compaction(Pid, Compaction, State)
  +        end,
  +    {reply, ok, StateName, NewState};
  +handle_sync_event({force_compact_view, Bucket, DDocId}, _From, StateName, State) ->
  +    Name = <<Bucket/binary, $/, DDocId/binary>>,
  +    Compaction = #forced_compaction{type=view, name=Name},
  +
  +    NewState =
  +        case is_already_being_compacted(Compaction, State) of
  +            true ->
  +                State;
  +            false ->
  +                {Config, _} = compaction_config(Bucket),
  +                Pid = spawn_view_compactor(Bucket, DDocId, Config, true),
  +                register_forced_compaction(Pid, Compaction, State)
  +        end,
  +    {reply, ok, StateName, NewState};
   handle_sync_event(Event, _From, StateName, State) ->
       ?log_warning("Got unexpected sync event ~p (when in ~p):~n~p",
                    [Event, StateName, State]),
  
positive.code:                  to_minute,
                   abort_outside}).
  
  -record(forced_compaction, {type, name}).
  
  % If N vbucket databases of a bucket need to be compacted, we trigger compaction
  % for all the vbucket databases of that bucket.
  
negative.code:                               [Type, Name, Reason])
              end,
  
              {next_state, StateName, unregister_forced_compaction(Pid, State)};
          error ->
              ?log_error("Unexpected process termination ~p: ~p. Dying.",
                         [Pid, Reason]),
  