Re: PostgreSql: Canceled on conflict out to old pivot - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: PostgreSql: Canceled on conflict out to old pivot
Date
Msg-id 590f3e4d-a561-43aa-b4a6-ee72387af275@iki.fi
Whole thread Raw
In response to Re: PostgreSql: Canceled on conflict out to old pivot  ("Wirch, Eduard" <eduard.w@smart-host.com>)
Responses Re: PostgreSql: Canceled on conflict out to old pivot
List pgsql-hackers
On 30/11/2023 18:24, Wirch, Eduard wrote:
>  > > The longest transaction that could occur is 1 min long.
>> I hate to drill on this, but are you very sure about that? A transaction 
> in a different database?
> 
> Don't be sorry for that, drilling down is important. ;) It took me so 
> long to reply because I had to prepare the information carefully. You're 
> right, on that day I observed the behavior, there were indeed long 
> running transactions in different DBs!

A-ha! :-D

> My understanding of serializable isolation is that only transactions
> which can somehow affect each other can conflict. It should be clear
> for PostgreSql, that transactions belonging to different databases
> cannot affect each other. Why do they cause serializable conflicts?

When the system runs low on the memory reserved to track the potential 
conflicts, it "summarizes" old transactions and writes them to disk. The 
summarization loses a lot of information: all we actually store on disk 
is the commit sequence number of the earliest "out-conflicting" 
transaction. We don't store the database oid that the transaction ran in.

The whole SSI mechanism is conservative so that you can get false 
serialization errors even when there is no actual problem. This is just 
an extreme case of that.

Perhaps we should keep more information in the on-disk summary format. 
Preserving the database OID would make a lot of sense, it would be only 
4 bytes extra per transaction. But we don't preserve it today.

> If you want something visual, I prepared a SO question with similar 
> content like this mail, but added an image of the tx flow: 
> https://stackoverflow.com/questions/77544821/postgresql-canceled-on-conflict-out-to-old-pivot
<https://stackoverflow.com/questions/77544821/postgresql-canceled-on-conflict-out-to-old-pivot>

Nice graphs!

-- 
Heikki Linnakangas
Neon (https://neon.tech)




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: should check collations when creating partitioned index
Next
From: Heikki Linnakangas
Date:
Subject: Re: Refactoring backend fork+exec code