couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ayende Rahien" <aye...@ayende.com>
Subject Re: couch_util:new_uuid problem?
Date Sat, 04 Oct 2008 00:53:40 GMT
Another question:    % go ahead and generate the new revision ids for the
documents.
    Docs2 = lists:map(
        fun(#doc{id=Id,revs=Revs}=Doc) ->
            case Id of
            <<?LOCAL_DOC_PREFIX, _/binary>> ->
                Rev = case Revs of [] -> 0; [Rev0|_] ->
list_to_integer(binary_to_list(Rev0)) end,
                Doc#doc{revs=[list_to_binary(integer_to_list(Rev + 1))]};
            _ ->

 Doc#doc{revs=[list_to_binary(integer_to_list(couch_util:rand32())) | Revs]}
            end
        end, Docs),

A) we have the same problem with rand32(), from the code, I assume it is
meant to generate a revision that can be unique across nodes, but it is not
guaranteed.
B) What is the meaning of "_local" documents? I couldn't find anything about
it.

On Sat, Oct 4, 2008 at 2:49 AM, Ayende Rahien <ayende@ayende.com> wrote:

> Looking at the method implementation, it looks like there might be a
> problem here.
>
> new_uuid() ->
>     list_to_binary(to_hex(crypto:rand_bytes(16))).
>
> In particular, we aren't actually guaranteed to have a unique value.
> You can read more about what needs to be done to get unique guids: here:
> http://blogs.msdn.com/oldnewthing/archive/2008/06/27/8659071.aspx
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message