Skip to content

[Uid] Uuid v7 collisions #52338

Closed
Closed
@vudaltsov

Description

@vudaltsov

Symfony version(s) affected

6.3.0

Description

From time to time I get UUID v7 collisions.

How to reproduce

<?php

// generate_uuids_v7.php

use Symfony\Component\Uid\Uuid;

require_once __DIR__.'/vendor/autoload.php';

for ($j = 0; $j < 100; ++$j) {
    $uuids = '';

    for ($i = 0; $i < 1_000_000; ++$i) {
        $uuids .= Uuid::v7()->toRfc4122()."\n";
    }

    file_put_contents('uuids_v7.txt', $uuids, $j === 0 ? 0 : FILE_APPEND);
}
php generate_uuids_v7.php && sort uuids_v7.txt | uniq -cd

Expected behavior

Empty

Actual output (native PHP v8.2.10, macOS Ventura v13.3.1)

   2 018b73a2-4779-7f97-b675-5ce7ed6e1812
   2 018b73a2-9c97-7484-8a67-420747e8164a
   2 018b73a3-0f1b-7ac9-89dc-2b7f1e3625aa
   2 018b73a3-4da3-7bf5-bf20-aeaa68c6b109
   2 018b73a3-d9de-7850-9463-f4ee48ebfb02
   2 018b73a4-d6f4-7c55-a660-22114e5bf692
   2 018b73a5-f11b-7c99-884b-d741e7686016

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions