Re: There is a defect in the ReplicationSlotCreate() function where it iterates through ReplicationSlotCtl->replication_slots[max_replication_slots] to find a slot but does not break out of the loop when a slot is found. - Mailing list pgsql-bugs

From Daniel Gustafsson
Subject Re: There is a defect in the ReplicationSlotCreate() function where it iterates through ReplicationSlotCtl->replication_slots[max_replication_slots] to find a slot but does not break out of the loop when a slot is found.
Date
Msg-id D57D44E8-C6FE-41FD-9D43-105BB9B73366@yesql.se
Whole thread Raw
Responses Re: There is a defect in the ReplicationSlotCreate() function where it iterates through ReplicationSlotCtl->replication_slots[max_replication_slots] to find a slot but does not break out of the loop when a slot is found.
List pgsql-bugs
> On 14 Jan 2025, at 05:24, lxiaogang5 <lxiaogang5@gmail.com> wrote:

> There is a logical defect in the function ReplicationSlotCreate (creating a new slot) when it internally traverses
theReplicationSlotCtl->replication_slots[max_replication_slots] array. When an available slot is found (slot = s), it
shouldbreak the current for loop. This issue still exists in the latest code, resulting in wasted CPU resources. 

We could exit early, but any system which max_replication_slots set high enough
that the savings are measurable in a non-hot codepath is likely having other
performance problems as well (max_replication_slots is by default 10).

If you feel strongly about I suggest creating a patch and submitting.  Also,
please don't send 6Mb images of text when simply copy/paste of the text would
have worked even better.

--
Daniel Gustafsson




pgsql-bugs by date:

Previous
From: Ruben Ruiz
Date:
Subject: Re: BUG #18771: ICU custom collations with rules ignore collator strength option.
Next
From: Tom Lane
Date:
Subject: Re: There is a defect in the ReplicationSlotCreate() function where it iterates through ReplicationSlotCtl->replication_slots[max_replication_slots] to find a slot but does not break out of the loop when a slot is found.