On 2020-Apr-29, Vinicius Abrahao wrote:
> Hello PG Hackers
>
> Hope you are well and safe!
>
> I'm opening this thread to clarify something that I can observe: duplicated
> values for sequences.
>
> [My understanding is that duplication is not something we desire. In fact
> it does NOT happen in the majority of cases, for example, when you
> immediately insert the value and commit it. But it can eventually happen in
> some specific scenarios...describe below]
Hi Vinicius
I'm not sure that a sequence that produces the same value twice, without
writing it to the database the first time, and with an intervening crash
in between, is necessarily a bug that we care to fix. Especially so if
the fix will cause a large performance regression for the normal case
where the sequence value is written to the DB by a committed transaction.
(I think you could also cause the same problem with an async-commit
transaction that does write the value to the database, but whose writes
are lost in the crash ... since the WAL record for the sequence would
also be lost.)
Is there some valid reason to be interested in that scenario?
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services