Re: Commit Timestamp and LSN Inversion issue

From: Jan Wieck <jan(at)wi3ck(dot)info>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>
Cc: Andres Freund <andres(at)anarazel(dot)de>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Jan Wieck <jan(at)wi3ck(dot)info>
Subject: Re: Commit Timestamp and LSN Inversion issue
Date: 2024-11-14 13:50:31
Message-ID: 00888abf-dbda-4a58-8af1-8de6a54f1f4e@wi3ck.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/13/24 03:56, Amit Kapila wrote:

> the key point Andres
> is raising is that we won't be able to convert the operation in
> ReserveXLogInsertLocation() to use atomics after such a solution. Now,
> even, if the change is only in the *commit* code path, we may or may
> not be able to maintain two code paths for reserving LSN, one using
> atomics and the other (for commit record) using spinlock.

Which is only partially true. There is nothing that would prevent us
from using atomic operations inside of a spinlock and only reserving
xlog space for commit records needs a spinlock because of the extra
logic that cannot be combined into a single atomic operation. The idea
as I understand Andres is that changing ReserveXLogInsertLocation() to
use atomics gets rid not only of the spinlock, but also the LW-locks
that protect it from a spinlock storm.

Keeping the current LW-lock plus spinlock architecture only for commit
records but changing the actual reserve to atomic operations would
affect small transactions more than large ones. Making all of this
depend on "wal_level = logical" removes the argument that the two
solutions are mutually exclusive. It does however make the code less
maintenance friendly.

Best Regards, Jan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2024-11-14 14:13:17 Re: Refactoring postmaster's code to cleanup after child exit
Previous Message Amul Sul 2024-11-14 13:40:03 Re: NOT ENFORCED constraint feature