anchor.diff:                   true ->
                        ?xdcr_debug("rep (bucket: ~p, vbucket ~p) issues an empty open ckpt, no need to wait (open ckpt: ~p, persisted ckpt: ~p)",
                                    [Bucket, VBucket, OpenCheckpointId, PersistedCkptId]),
  -                     {ok, PersistedCkptId};
  +                     ok;
                    _ ->
                        %% waiting for persisted ckpt to catch up, time out in milliseconds
  -                     ?xdcr_debug("rep (bucket: ~p, vbucket ~p) waiting for chkpt persisted (open ckpt: ~p, timeout: ~p secs)",
  -                                 [Bucket, VBucket, OpenCheckpointId, TimeoutSec]),
  -                     ensure_full_commit_loop(OpenCheckpointId, TimeoutSec*1000)
  +                     ?xdcr_debug("rep (bucket: ~p, vbucket ~p)  wait for priority chkpt persisted: ~p",
  +                                 [Bucket, VBucket, (OpenCheckpointId-1)]),
  +                     wait_priority_checkpoint_persisted(Bucket, list_to_integer(VBucket), (OpenCheckpointId - 1))
                end,
   
  -    ns_pubsub:unsubscribe(LinkPid),
  -
  -    %% clear all unprocessed msg
  -    clear_ckpt_msg_loop(),
  -
       case Result of
  -        {ok, LastPersistedCkptId} ->
  +        ok ->
               {ok, Stats2} = ns_memcached:stats(Bucket, <<"">>),
               EpStartupTime = proplists:get_value(<<"ep_startup_time">>, Stats2),
               WorkTime = timer:now_diff(now(), StartTime) div 1000,
  -            ?xdcr_debug("last persisted ckpt: ~p, open ckpt: ~p for rep (bucket: ~p, vbucket ~p), "
  +            ?xdcr_debug("persistend open ckpt: ~p for rep (bucket: ~p, vbucket ~p), "
                           "time spent in millisecs: ~p",
  -                        [LastPersistedCkptId, OpenCheckpointId, Bucket, VBucket, WorkTime]),
  +                        [OpenCheckpointId, Bucket, VBucket, WorkTime]),
   
               {ok, EpStartupTime};
           timeout ->
  
positive.code:             {error, time_out_polling}
      end.
  
  ensure_full_commit_loop(OpenCheckpointId, Timeout) ->
      receive
          {persisted_ckpt, PersistedCheckpointId} ->
              case PersistedCheckpointId >= (OpenCheckpointId - 1) of
                  true ->
                      {ok, PersistedCheckpointId};
                  _ ->
                      ensure_full_commit_loop(OpenCheckpointId, Timeout)
              end
      after Timeout ->
              timeout
      end.
  
  clear_ckpt_msg_loop() ->
      receive
          {persisted_ckpt, _PersistedCheckpointId} ->
              clear_ckpt_msg_loop()
      after 0 ->
              ok
      end.
  
  check_is_admin(_Db) ->
      ok.
  
negative.code:         end,
      Result.
  
  
  %% new ensure_full_commit uses CMD_CHECKPOINT_PERSISTENCE to issue
  %% priority checkpoint
  -spec ensure_full_commit(any(), integer()) -> {ok, binary()}.
  ensure_full_commit(#db{filepath = undefined} = _Db, _RequiredSeq) ->
      {ok, <<>>};
  
  ensure_full_commit(#db{name = DbName} = _Db, _RequiredSeq) ->
      [Bucket, VBucket] = string:tokens(binary_to_list(DbName), [$/]),
  
      %% create a new open checkpoint
      StartTime = now(),
  