BigSerial and txid issuance

From: "Yorwerth, Adam" <Adam(dot)Yorwerth(at)tesco(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Cc: "Cianciaruso, Lorenzo" <lorenzo(dot)cianciaruso(at)tesco(dot)com>
Subject: BigSerial and txid issuance
Date: 2020-07-08 14:09:22
Message-ID: 4478EF79-0699-4FBA-B7C1-95561EF1DB5E@tesco.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Everyone,

We’re trying to solve a problem that relies on BigSerial and txid (as returned by txid_current() ) values being issued consistently.

Is it possible for two transactions to interleave their issuance of these two variables?

For example:

Schema:

CREATE TABLE EXAMPLE(
offset bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL,
txid BIGINT NOT NULL DEFAULT 1
);

Insert statement:

"INSERT INTO EVENTS (txid) VALUES (txid_current());";

Prior to transactions executing offset is 10 and txid is 1000.

Transaction 1 and 2 occur concurrently.

Is it possible for transaction 1 to be issued txid 1001 and offset 12 and transaction 2 to be issued txid 1002 and offset 11?

Any help would be much appreciated.

Regards,

Adam
This is a confidential email. Tesco may monitor and record all emails. The views expressed in this email are those of the sender and not Tesco. Tesco Stores Limited Company Number: 519500 Registered in England Registered Office: Tesco House, Shire Park, Kestrel Way, Welwyn Garden City, AL7 1GA VAT Registration Number: GB 220 4302 31

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2020-07-08 14:16:00 Re: Is this a bug in pg_current_logfile() on Windows?
Previous Message Adrian Klaver 2020-07-08 13:45:12 Re: Is this a bug in pg_current_logfile() on Windows?