anchor.diff:            VBucketName <- [binary:part(FullName, PrefixLen, erlang:size(FullName) - PrefixLen)],
             VBucketName =/= <<"master">>]).
   
  -apply_vbucket_states(Bucket, WantedStates, RebalanceStates, UseReplicaIndex, ExistingVBuckets) ->
  -    SetName = list_to_binary(Bucket),
  -    {Active, Passive, MainCleanup, Replica, ReplicaCleanup, PauseVBuckets, UnpauseVBuckets} =
  -        compute_index_states(WantedStates, RebalanceStates, ExistingVBuckets),
  -    do_apply_vbucket_states(SetName, Active, Passive, MainCleanup, Replica, ReplicaCleanup, PauseVBuckets, UnpauseVBuckets, UseReplicaIndex).
  -
  -
  -do_apply_vbucket_states(SetName, Active, Passive, MainCleanup, Replica, ReplicaCleanup, PauseVBuckets, UnpauseVBuckets, UseReplicaIndex) ->
  +do_apply_vbucket_states(SetName, Active, Passive, MainCleanup, Replica, ReplicaCleanup, PauseVBuckets, UnpauseVBuckets, State) ->
       RVs = capi_ddoc_replication_srv:foreach_live_ddoc_id(
               SetName,
               fun (DDocId) ->
                       apply_index_states(SetName, DDocId,
                                          Active, Passive, MainCleanup, Replica, ReplicaCleanup,
                                          PauseVBuckets, UnpauseVBuckets,
  -                                       UseReplicaIndex),
  +                                       State),
                       ok
               end),
       BadDDocs = [Pair || {_Id, Val} = Pair <- RVs,
  
positive.code:             %% The document has been deleted but we still think it's
              %% alive. Eventually we will get a notification from master db
              %% watcher and delete it from a list of design documents.
              ok
      end.
  
  maybe_define_group(DDocId, State) ->
      try
          define_group(DDocId, State),
          ok
      catch
          throw:view_already_defined ->
              already_defined
      end.
  
  apply_index_states(SetName, DDocId, Active, Passive, Cleanup,
                     Replica, ReplicaCleanup, PauseVBuckets, UnpauseVBuckets, UseReplicaIndex) ->
  
      try
          PausingOn = cluster_compat_mode:is_index_pausing_on(),
  
negative.code: master_db(Bucket) ->
      list_to_binary(Bucket ++ "/master").
  
  maybe_define_group(DDocId,
                     #state{bucket = Bucket,
                            num_vbuckets = NumVBuckets,
                            use_replica_index = UseReplicaIndex} = _State) ->
      SetName = list_to_binary(Bucket),
      Params = #set_view_params{max_partitions=NumVBuckets,
                                active_partitions=[],
  