Re: There is a defect in the ReplicationSlotCreate() function whereit iterates throughReplicationSlotCtl->replication_slots[max_replication_slots] to find a slotbut does not break out of the loop when a slot is found.

From: lxiaogang5 <lxiaogang5(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: There is a defect in the ReplicationSlotCreate() function whereit iterates throughReplicationSlotCtl->replication_slots[max_replication_slots] to find a slotbut does not break out of the loop when a slot is found.
Date: 2025-01-15 02:03:28
Message-ID: tencent_C9916D9ADB19FCA6B55DAC0C@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

<div style="min-height:22px;margin-bottom:8px;"><br></div><div style="min-height:22px;margin-bottom:8px;">Yes, it's this piece of code. Thank you for your patient explanation. What you said makes a lot of sense. Even after obtaining the available slots, we still need to traverse and check if there are any duplicate slots.</div><div id="QQMailSignature" class="mail-footer" aria-hidden="true"><hr style="margin: 0 0 10px 0;border: 0;border-bottom:1px solid #E6E8EB;height:0;line-height:0;font-size:0;padding: 20px 0 0 0;width: 50px;">发自我的iPhone</div><div id="original-content"><br><br><div class="xm_mail_oringinal_describe"><div style="font-size:70%;padding:2px 0;">------------------ Original ------------------</div><div style="font-size:70%;background:#f0f0f0;color:#212121;padding:8px;border-radius:4px"><div><b>From:</b> Daniel Gustafsson &lt;daniel(at)yesql(dot)se&gt;</div><div><b>Date:</b> Tue,Jan 14,2025 6:57 PM</div><div><b>To:</b> lxiaogang5 &lt;lxiaogang5(at)gmail(dot)com&gt;</div><div><b>Cc:</b> pgsql-bugs &lt;pgsql-bugs(at)postgresql(dot)org&gt;</div><div><b>Subject:</b> Re: There is a defect in the ReplicationSlotCreate() function whereit iterates throughReplicationSlotCtl-&gt;replication_slots[max_replication_slots] to find a slotbut does not break out of the loop when a slot is found.</div></div></div><br><pre style="white-space:pre-wrap;">&gt; On 14 Jan 2025, at 05:24, lxiaogang5 &lt;lxiaogang5(at)gmail(dot)com&gt; wrote:

&gt; There is a logical defect in the function ReplicationSlotCreate (creating a new slot) when it internally traverses the ReplicationSlotCtl-&gt;replication_slots[max_replication_slots] array. When an available slot is found (slot = s), it should break 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

</pre></div>

Attachment Content-Type Size
unknown_filename text/html 2.2 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2025-01-15 05:59:20 BUG #18773: オートバキュームのリトライ時にreltuplesの値が減少する
Previous Message Tom Lane 2025-01-15 00:33:44 Re: BUG #18772: Segfaul i Greek stemming