| From: | Xuneng Zhou <xunengzhou(at)gmail(dot)com> |
|---|---|
| To: | "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com> |
| Cc: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Fix race in ReplicationSlotRelease for ephemeral slots |
| Date: | 2026-06-17 07:08:40 |
| Message-ID: | CABPTF7Vyt13sex0VCQaVSw-4Hiru5=nL9S-9GkfRDQAMwUFe8A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Jun 16, 2026 at 6:32 PM Zhijie Hou (Fujitsu)
<houzj(dot)fnst(at)fujitsu(dot)com> wrote:
>
> On Tuesday, June 16, 2026 5:36 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> >
> > On Tue, Jun 16, 2026 at 2:24 PM Zhijie Hou (Fujitsu) <houzj(dot)fnst(at)fujitsu(dot)com>
> > wrote:
> > >
> > >
> > > I have one minor comment for the 0001 patch.
> > >
> > > + NameData slot_name = {0};
> > > ...
> > > SpinLockAcquire(&local_slot->mutex);
> > > synced_slot = local_slot->in_use &&
> > > local_slot->data.synced;
> > > + if (synced_slot)
> > > + slot_name = local_slot->data.name;
> > > SpinLockRelease(&local_slot->mutex);
> > >
> > > We can defer assigning slot_name until after we pass the existing
> > > (synced_slot) check. Since it's a synced slot, no other process can
> > > change it at that point, and we can also skip initializing slot_name.
> > > (Please refer to the attached patch for suggested changes)
> > >
This seems ok to me. The only risk is that people who don't know the
assumption might think this getter is unsafe.
> > + if (dropped)
> > + ereport(LOG,
> > + errmsg("dropped replication slot \"%s\" of database with OID %u",
> > + NameStr(slot_name),
> > + slot_database));
> >
> > Can we avoid the if (dropped) check by placing this LOG message immediately
> > after dropping the slot under synced slot check?
>
> I think we can do that.
+1. Placing the log message within the lock window looks OK to me
since the cost is small.
> I'm attaching the new patches for all supported
> branches, incorporating both my and Amit's comments. I hope this helps move the
> fix forward.
>
> I also confirmed that the fix works on all supported branches.
Thanks for your preparation for patches and confirmation of them!
--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pavel Stehule | 2026-06-17 07:20:52 | Re: proposal - queryid can be used as filter for auto_explain |
| Previous Message | Peter Smith | 2026-06-17 07:06:43 | Re: Support EXCEPT for ALL SEQUENCES publications |