anchor.diff:                      error_logger:info_msg(
                         "~p:sanify: Setting master ~p from ~p to active for vbucket ~p~n",
                         [?MODULE, Master, State, VBucket]),
  -                    ns_memcached:set_vbucket_state(Master, Bucket, VBucket, active);
  +                    ns_memcached:set_vbucket_state(Master, Bucket, VBucket, active),
  +                    Chain;
  +                [Node] ->
  +                    %% One active node, but it's not the master
  +                    case lists:position(Node, Chain) of
  +                        undefined ->
  +                            %% It's an extra node
  +                            error_logger:info_msg(
  +                              "~p:sanify: Master for vbucket ~p is not active, but ~p is, so making that the master.~n",
  +                              [?MODULE, VBucket, Node]),
  +                            [Node|lists:duplicate(length(Chain) - 1,
  +                                                  undefined)];
  +                        Pos ->
  +                            [Node|lists:nthtail(1, Pos)]
  +                    end;
                   Nodes ->
                       error_logger:error_msg(
  -                      "~p:sanify: Extra active nodes ~p for vbucket ~p. If there is only one, we should probably just change the map, but this should never happen, so I'm going to do nothing.~n",
  -                      [?MODULE, Nodes, VBucket])
  +                      "~p:sanify: Extra active nodes ~p for vbucket ~p. This should never happen!~n",
  +                      [?MODULE, Nodes, VBucket]),
  +                    Chain
               end;
           C = [{_, active}|ReplicaStates] ->
               lists:foreach(
  
positive.code:     case ChainStates of
          [{undefined, _}|_] ->
              error_logger:info_msg("~p:sanify: No master for vbucket ~p~n",
                                    [?MODULE, VBucket]);
          [{Master, State}|ReplicaStates] when State == pending orelse
                                               State == replica ->
              %% If we have any active nodes, do nothing, otherwise, set
  
negative.code: -export([cleanup/3, current_states/2, graphviz/1]).
  
  cleanup(Bucket, Map, Servers) ->
      case sanify(Bucket, Map, Servers) of
          Map -> ok;
          Map1 ->
              error_logger:info_msg("~p:sanify changed map: ~p~n", [?MODULE, Map1]),
              ns_bucket:set_map(Bucket, Map1)
      end,
      Replicas = lists:keysort(1, map_to_replicas(Map)),
      ReplicaGroups = lists:ukeymerge(1, misc:keygroup(1, Replicas),
                                      [{N, []} || N <- lists:sort(Servers)]),
  