anchor.diff:      try
           update_db_doc(Db, Doc)
       catch conflict ->
  -        ok % assume this is a race with another shard on this node
  +        % one more check to detect a real conflict
  +        #doc{id=Id, body=Body} = Doc,
  +        case couch_db:open_doc(Db, Id, []) of
  +        {ok, #doc{body=Body}} ->
  +            % assume this is a race with a replication
  +            ok;
  +        {ok, _} ->
  +            conflict
  +        end
       after
           couch_db:close(Db)
       end.
  
positive.code:     end.
  
  delete_db_doc(Db, DocId) ->
      case couch_db:open_doc(Db, DocId, []) of
      {not_found, _} ->
          ok;
      {ok, OldDoc} ->
          {ok, _} = couch_db:update_doc(Db, OldDoc#doc{deleted=true}, [])
      end.
  
  build_shards(DbName, DocProps) ->
      {ByNode} = couch_util:get_value(<<"by_node">>, DocProps, {[]}),
  
negative.code: update_db_doc(Db, #doc{id=Id, body=Body} = Doc) ->
      case couch_db:open_doc(Db, Id, []) of
      {not_found, _} ->
          {ok, _} = couch_db:update_doc(Db, Doc, []),
          ok;
      % harmless race condition
      {ok, #doc{body=Body}} ->
          ok;
      % real conflict
      {ok, _} ->
          conflict
      end.
  
  delete_db_doc(DocId) ->
  