anchor.diff:  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, _} = couch_db:update_doc(Db, Doc, []),
  +        ok;
  +    % harmless race condition
       {ok, #doc{body=Body}} ->
           ok;
  -    {ok, OldDoc} ->
  -        {ok, _} = couch_db:update_doc(Db, OldDoc#doc{body=Body}, [])
  +    % real conflict
  +    {ok, _} ->
  +        conflict
       end.
   
   delete_db_doc(DocId) ->
  
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:     try
          update_db_doc(Db, Doc)
      catch conflict ->
          % 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.
  