Re: Atomic ops for unlogged LSN

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Atomic ops for unlogged LSN
Дата
Msg-id 20231108011811.elqq3e67burgik7x@awork3.anarazel.de
обсуждение исходный текст
Ответ на Re: Atomic ops for unlogged LSN  (John Morris <john.morris@crunchydata.com>)
Список pgsql-hackers
Hi,

On 2023-11-07 00:57:32 +0000, John Morris wrote:
> I found the comment about cache coherency a bit confusing. We are dealing
> with a single address, so there should be no memory ordering or coherency
> issues. (Did I misunderstand?) I see it more as a race condition.

IMO cache coherency covers the value a single variable has in different
threads / processes.

In fact, the only reason there effectively is a guarantee that you're not
seeing an outdated unloggedLSN value during shutdown checkpoints, even without
the spinlock or full barrier atomic op, is that the LWLockAcquire(), a few
lines above this, would prevent both the compiler and CPU from moving the read
of unloggedLSN to much earlier.  Obviously that lwlock has a different
address...


If the patch just had done the minimal conversion, it'd already have been
committed...  Even if there'd be a performance reason to get rid of the memory
barrier around reading unloggedLSN in CreateCheckPoint(), I'd do the
conversion in a separate commit.

Greetings,

Andres Freund



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: Add new option 'all' to pg_stat_reset_shared()
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Show WAL write and fsync stats in pg_stat_io