Re: Get rid of WALBufMappingLock

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com>, Victor Yegorov <vyegorov(at)gmail(dot)com>, Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Kirill Reshke <reshke(at)yandex-team(dot)ru>
Subject: Re: Get rid of WALBufMappingLock
Date: 2025-02-26 08:52:17
Message-ID: C27929F1-4932-42A1-8B9B-EACBEEBDB0EB@yandex-team.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 25 Feb 2025, at 20:19, Alexander Korotkov <aekorotkov(at)gmail(dot)com> wrote:
>
>

Hi!

One little piece of code looks suspicious to me. But I was not raising concern because I see similar code everywhere in the codebase. But know Kirill asked to me explain what is going on and I cannot.

This seems to be relevant… so.

+ while (upto >= pg_atomic_read_u64(&XLogCtl->InitializedUpTo))
// Assume ConditionVariableBroadcast() happened here, but before next line
+ ConditionVariableSleep(&XLogCtl->InitializedUpToCondVar, WAIT_EVENT_WAL_BUFFER_INIT);
+ ConditionVariableCancelSleep();

Won’t this sleep wait forever?

I see about 20 other occurrences of similar code, so, perhaps, everything is fine. But I would greatly appreciate a little pointers on why it works.

Best regards, Andrey Borodin.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-02-26 08:53:17 Re: Adding a '--two-phase' option to 'pg_createsubscriber' utility.
Previous Message Jakub Wartak 2025-02-26 08:48:41 Re: Draft for basic NUMA observability