Re: SEQUENCE values (duplicated) in some corner cases when crashhappens - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: SEQUENCE values (duplicated) in some corner cases when crashhappens
Date
Msg-id 20200429162907.GA20528@alvherre.pgsql
Whole thread Raw
In response to SEQUENCE values (duplicated) in some corner cases when crash happens  (Vinicius Abrahao <vinnix.bsd@gmail.com>)
Responses Re: SEQUENCE values (duplicated) in some corner cases when crash happens  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: tablespace_map code cleanup
Next
From: Mark Dilger
Date:
Subject: Re: new heapcheck contrib module