Re: UUID v7

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>
Cc: Daniel Verite <daniel(at)manitou-mail(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, Sergey Prokhorenko <sergeyprokhorenko(at)yahoo(dot)com(dot)au>, Przemysław Sztoch <przemyslaw(at)sztoch(dot)pl>, Michael Paquier <michael(at)paquier(dot)xyz>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, Pgsql-Hackers Mailing List <pgsql-hackers(at)postgresql(dot)org>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Mat Arye <mat(at)timescaledb(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>, Junwang Zhao <zhjwpku(at)gmail(dot)com>, Stepan Neretin <sncfmgg(at)gmail(dot)com>
Subject: Re: UUID v7
Date: 2024-12-09 22:34:38
Message-ID: CAD21AoAJ5ETmSUgm9OL7qR_7Ogm9FPsVn+AwkA4Dr4JrrDQPEg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 4, 2024 at 9:04 AM Andrey M. Borodin <x4mmm(at)yandex-team(dot)ru> wrote:
>
>
>
> > On 2 Dec 2024, at 11:00, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> >
> > The monotonicity of generated UUIDv7 is guaranteed only within a
> > single backend.
>
> I've addressed all items, except formatting a table... I can't build docs to make a reasonable judgement if the table looks OK.
>

Thank you for updating the patch!

> Changes:
> - restored leakproof flag of functions without arguments to be consistent with gen_random_uuid()

If I understand the below Peter's comment correctly, we don't need to
mark all of three functions leakproof:

>
> * src/test/regress/expected/opr_sanity.out
>
> +uuidv4()
> +uuidv7()
> +uuidv7(interval)
>
> Functions without arguments don't need to be marked leakproof.
>
> uuidv7(interval) internally calls timestamptz_pl_interval(), which is
> not leakproof, so I don't think that classification is sound.

I've attached the updated patches. The 0001 patch unmarks the existing
gen_random_uuid() leakproof and is being discussed on another
thread[1]. I'm going to push the main UUIDv7 patch barring objections
and further comments, after pushing the fix for gen_random_uuid().

>
> Also PFA a prototype of making uuidv7() ordered across all backends via keeping previous_ns in shared memory. IMO it's overcomplicating and RFC does not require such guarantees. Also, this would cost us several hundreds of ns on each uuidv7() call. I think we should focus on committing existing implementation and leave such things for a future improvement.

I also feel like it's overcomplicating. We can focus on the main patch
and can implement it later if we really need it.

Regards,

[1] https://www.postgresql.org/message-id/CAD21AoBE1ePPWY1NQEgk3DkqjYzLPZwYTzCySHm0e%2B9a69PfZw%40mail.gmail.com

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v42-0001-Unmark-gen_random_uuid-leakproof.patch application/x-patch 1.5 KB
v42-0002-Add-UUID-version-7-generation-function.patch application/x-patch 21.8 KB

In response to

  • Re: UUID v7 at 2024-12-04 16:44:54 from Andrey M. Borodin

Responses

  • Re: UUID v7 at 2024-12-10 03:42:24 from Andrey M. Borodin

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2024-12-09 22:39:03 Re: psql: Add tab completion for ALTER USER RESET
Previous Message Michael Harris 2024-12-09 22:34:08 Re: FileFallocate misbehaving on XFS