anchor.diff:      lists:map(
           fun([XDocId,
                #rep{source = SrcBucket,
  -                  target = {_, TgtBucket, _, _, _, _, _, _, _, _}}]) ->
  -            case failed_couch_replications(XDocId) of
  -            [] ->
  -                ?log_info("~s: no failed vbucket replications found",
  -                          [XDocId]),
  -                ok;
  -            FailedReps ->
  -                % Reread the target vbucket map once before retrying all failed
  -                % replications
  -                {ok, TgtVbInfo} =
  +                  target = {_, TgtBucket, _, _, _, _, _, _, _, _}},
  +             TriggeredVbs, UntriggeredVbs]) ->
  +
  +            FailedCouchReps = failed_couch_replications(XDocId),
  +            case {FailedCouchReps, UntriggeredVbs} of
  +            {[], []} ->
  +                ?log_info("~s: no failed vbucket replications found", [XDocId]);
  +            {_, _} ->
  +                % Reread the target vbucket map once before retrying all reps
  +                {ok, {TgtVbMap, TgtNodes} = TgtVbInfo} =
                       xdc_rep_utils:remote_vbucketmap_nodelist(TgtBucket),
  +
  +                % Retry couch replications that failed after they were triggered
                   lists:map(
  -                    fun(FailedRep) ->
  +                    fun(FailedCouchRep) ->
                           retry_couch_replication(XDocId, SrcBucket, TgtVbInfo,
  -                                                FailedRep)
  +                                                FailedCouchRep)
                       end,
  -                    FailedReps)
  +                    FailedCouchReps),
  +
  +                % Retry couch replications that did not trigger at all
  +                {TriggeredVbs1, UntriggeredVbs1} = start_vbucket_replications(
  +                    XDocId, SrcBucket, TgtVbMap, TgtNodes, UntriggeredVbs, 0),
  +                true = ets:update_element(
  +                    ?XSTORE, XDocId, [{3, (TriggeredVbs ++ TriggeredVbs1)},
  +                                      {4, UntriggeredVbs1}])
               end
           end,
  -        ets:match(?XSTORE, {'$1', '$2', '_'})).
  +        ets:match(?XSTORE, {'$1', '$2', '$3', '$4'})).
   
   
   retry_couch_replication(XDocId,
  
positive.code:     case {SrcBucketLookup, TgtBucketLookup} of
      {not_present, not_present} ->
          ?log_error("~s: source and target buckets not found", [XDocId]),
          true = ets:insert(?XSTORE, {XDocId, XRep, []}),
          {error, not_present};
      {not_present, _} ->
          ?log_error("~s: source bucket not found", [XDocId]),
          true = ets:insert(?XSTORE, {XDocId, XRep, []}),
          {error, not_present};
      {_, not_present} ->
          ?log_error("~s: target bucket not found", [XDocId]),
          true = ets:insert(?XSTORE, {XDocId, XRep, []}),
          {error, not_present};
      {{ok, SrcBucketConfig}, {ok, {TgtVbMap, TgtNodes}}} ->
          MyVbuckets = xdc_rep_utils:my_active_vbuckets(SrcBucketConfig),
          {TriggeredVbuckets, _} = start_vbucket_replications(
              XDocId, SrcBucket, TgtVbMap, TgtNodes, MyVbuckets, 0),
          true = ets:insert(?XSTORE, {XDocId, XRep, TriggeredVbuckets}),
          create_xdc_rep_info_doc(XDocId, XRepId, TriggeredVbuckets, RepDbName,
                                  XDocBody),
          ok
      end.
  
negative.code:     % info doc as "cancelled"
      couch_replication_manager:update_rep_doc(
          xdc_rep_utils:info_doc_id(XDocId),
          xdc_rep_utils:vb_rep_state_list(LostVbs, <<"cancelled">>)),
  
      % Update XSTORE with the current active vbuckets list
      CurrTriggeredVbs = CurrVbs -- (PrevUntriggeredVbs ++ UntriggeredVbs1),
      CurrUntriggeredVbs = CurrVbs -- CurrTriggeredVbs,
      true = ets:update_element(?XSTORE, XDocId,
                                [{3, CurrTriggeredVbs}, {4, CurrUntriggeredVbs}]).
  
  
  % Given a list of vbuckets, this function attempts to trigger Couch replication
  