When should I use uuid.uuid1() vs. uuid.uuid4() in python?

后端 未结 6 1286
情话喂你
情话喂你 2020-12-07 07:43

I understand the differences between the two from the docs.

uuid1():
Generate a UUID from a host ID, sequence number, and the current time

<

6条回答
  •  旧时难觅i
    2020-12-07 08:17

    My team just ran into trouble using UUID1 for a database upgrade script where we generated ~120k UUIDs within a couple of minutes. The UUID collision led to violation of a primary key constraint.

    We've upgraded 100s of servers but on our Amazon EC2 instances we ran into this issue a few times. I suspect poor clock resolution and switching to UUID4 solved it for us.

提交回复
热议问题