couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nick North (Commented) (JIRA)" <>
Subject [jira] [Commented] (COUCHDB-1405) error generating document id with utc_random
Date Thu, 09 Feb 2012 08:39:00 GMT


Nick North commented on COUCHDB-1405:

I am unable to reproduce this on my 64-bit Windows 7 setup. The app I'm using creates a document
containing the current system time as one of its fields, and using  utc_random to create document
id (actually a slight variant, but it's using the utc_random code for the utc element). When
I fetch the document back and extract the UTC time from the document id, it agrees with the
system time field to a small fraction of a second, which is accounted for by the time taken
to submit the document to CouchDb. Running this for ten thousand or so documents over a 15-hour
period shows no drift in the times.

It's just possible that Hyper-V is affecting things in your case, though it feels unlikely.
utc_random just takes the time from Erlang's clock which, I assume, gets it from the same
place as a call to system time does. But virtualisation may do something odd there.

At the risk of asking a stupid question: is the system time that you are checking against
the document id taken from the CouchDb server itself, or some other machine on the network?
Your problem has all the symptoms of system clock drift between client and server machines.
The test I ran above was with the document creating app on the CouchDb server itself so that
the server time field in the document comes from the same system clock that is used to create
the utc_random doc id.
> error generating document id with utc_random
> --------------------------------------------
>                 Key: COUCHDB-1405
>                 URL:
>             Project: CouchDB
>          Issue Type: Bug
>          Components: Database Core
>    Affects Versions: 1.1.1
>         Environment: Windows 7, 64-bit, running as virtual pc in hyper-v
>            Reporter: André Bögge
> I use the utc_random algorithm for generating document ids. So it's possible for me to
calculate time and date out of the id in my client application. After running CouchDB for
about a month i got a difference between system time and calculated time of id of about half
an hour. I restarted the database and even then i got a difference about 1 minute.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message