failed to generate more than 1095 uuids
tj13 opened this issue · 5 comments
uuid.uuid1() will return strange uuids after 1095 generations.
step 1: create docker container
$ sudo docker run -d -it --name pypyt-test pypy:2 /bin/bash
step 2: sample code
root@1e65a430de73:/# cat /tmp/test.py
import sys, time, uuid
N = int(sys.argv[1])
t = time.time()
for x in xrange(N):
print uuid.uuid1()
step 3:
root@1e65a430de73:/# pypy /tmp/test.py 1099
...
02d62faa-9cb0-11e5-96db-0242ac110016
02d63270-9cb0-11e5-96db-0242ac110016
02d6359a-9cb0-11e5-96db-0242ac110016
02d6d5e0-9cb0-11e5-96db-0242ac110016
02d860d6-9cb0-11e5-96db-0242ac110016
01000000-0000-0000-0000-000000000000 - line num 1095
08c9287a-3c7f-0000-70b4-287a3c7f0000
88f5747a-3c7f-0000-2024-5a7a3c7f0000
ffffffff-ffff-ffff-2805-000000000000
Does it perform differently if you install pypy on your host? We don't do anything special to configure pypy, so it should perform the same as a standard pypy installation.
@tianon
docker container is running under AWS EC2 environment. the script works fine when running on the EC2 directly. pls refer the detail as below:
$ cat /tmp/test.py
import sys, time, uuid
N = int(sys.argv[1])
t = time.time()
for x in xrange(N):
print uuid.uuid1()
$ pypy /tmp/test.py 1999 | tail -n 5
ce4fd0ec-9d4a-11e5-80a9-0229a51978d1
ce4fd132-9d4a-11e5-80a9-0229a51978d1
ce4fd178-9d4a-11e5-80a9-0229a51978d1
ce4fd1be-9d4a-11e5-80a9-0229a51978d1
ce4fd3c6-9d4a-11e5-80a9-0229a51978d1
After some testing, it looks like this is a bug in PyPy 4.0.1. I get duplicates whether I run the pypy:2
image or install pypy
from apt in debian:sid
.
# this is how I was testing; which gives counts of all the uuids
$ docker run -it --rm -v "$PWD"/test.py:/test.py pypy:2 pypy /test.py 1999 | sort | uniq -c | sort -n
...
1 ffffffff-ffff-ffff-c87e-010000000000
2 00000000-0000-0000-0001-000000000000
2 00000000-0000-0000-d6ff-ffffffffffff
2 00010000-0000-0000-0000-000000000000
2 00010000-0000-0000-788f-050000000000
2 00010500-0000-0000-000f-050000000000
2 0001ffff-ffff-ffff-000f-050000000000
2 0001ffff-ffff-ffff-788f-050000000000
2 0001ffff-ffff-ffff-ffff-ffffffffffff
2 000f0500-0000-0000-d6ff-ffffffffffff
2 02000000-0000-0000-ffff-ffffffffffff
2 04000000-0000-0000-0400-000000000000
2 05000000-0000-0000-3200-000000000000
2 08000000-0000-0000-0800-000000000000
2 10cddfbf-337f-0000-ffff-ffffffffffff
2 10f60100-0000-0000-a0a0-51ba337f0000
2 28050000-0000-0000-0000-000000000000
2 28060000-0000-0000-0100-000000000000
2 30f60100-0000-0000-ffff-ffffffffffff
2 50710100-0000-0000-0800-000000000000
2 60a421ba-337f-0000-1000-000000000000
2 60a421ba-337f-0000-d6ff-ffffffffffff
2 788f0500-0000-0000-0000-000000000000
2 c87e0100-0000-0000-0000-000000000000
2 d6ffffff-ffff-ffff-0500-000000000000
2 d6ffffff-ffff-ffff-0700-000000000000
2 d6ffffff-ffff-ffff-ffff-ffffffffffff
2 e07d80c0-337f-0000-40f4-babf337f0000
2 ffffffff-ffff-ffff-0001-000000000000
3 00000000-0000-0000-1071-010000000000
3 00000000-0000-0000-6832-53ba337f0000
3 00000000-0000-0000-c0ab-ccbf337f0000
3 000f0500-0000-0000-0000-000000000000
3 01000000-0000-0000-0000-000000000000
3 02000000-0000-0000-0000-000000000000
3 28060000-0000-0000-2806-000000000000
3 d6ffffff-ffff-ffff-d6ff-ffffffffffff
3 ffffffff-ffff-ffff-d6ff-ffffffffffff
3 ffffffff-ffff-ffff-e015-080000000000
4 d6ffffff-ffff-ffff-0000-000000000000
5 00000000-0000-0000-0800-000000000000
5 00000000-0000-0000-ffff-ffffffffffff
6 000f0500-0000-0000-ffff-ffffffffffff
8 00000000-0000-0000-0100-000000000000
9 ffffffff-ffff-ffff-788f-050000000000
10 788f0500-0000-0000-ffff-ffffffffffff
10 ffffffff-ffff-ffff-000f-050000000000
17 ffffffff-ffff-ffff-ffff-ffffffffffff
71 00000000-0000-0000-0000-000000000000
import sys, time, uuid
N = int(sys.argv[1])
t = time.time()
for x in xrange(N):
print(uuid.uuid4())
exactly.
the docker images with tag 2-2.4.0 works fine. the issue is gone. really appreciate for your help!
PyPy 5.0 is out now, which includes the fix for this issue. Can we get a new image? (he asks, impatiently 😀)