public inbox for [email protected]
help / color / mirror / Atom feedFrom: Heikki Linnakangas <[email protected]>
To: Bertrand Drouvot <[email protected]>
To: [email protected]
Subject: Re: Missing LWLock protection in pgstat_reset_replslot()
Date: Tue, 5 Mar 2024 09:55:32 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
On 01/03/2024 12:15, Bertrand Drouvot wrote:
> Hi hackers,
>
> I think that pgstat_reset_replslot() is missing LWLock protection. Indeed, we
> don't have any guarantee that the slot is active (then preventing it to be
> dropped/recreated) when this function is executed.
Yes, so it seems at quick glance. We have a similar issue in
pgstat_fetch_replslot(); it might return stats for wrong slot, if the
slot is dropped/recreated concurrently. Do we care?
> --- a/src/backend/utils/activity/pgstat_replslot.c
> +++ b/src/backend/utils/activity/pgstat_replslot.c
> @@ -46,6 +46,8 @@ pgstat_reset_replslot(const char *name)
>
> Assert(name != NULL);
>
> + LWLockAcquire(ReplicationSlotControlLock, LW_SHARED);
> +
> /* Check if the slot exits with the given name. */
> slot = SearchNamedReplicationSlot(name, true);
SearchNamedReplicationSlot() will also acquire the lock in LW_SHARED
mode, when you pass need_lock=true. So that at least should be changed
to false.
--
Heikki Linnakangas
Neon (https://neon.tech)
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Missing LWLock protection in pgstat_reset_replslot()
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox