Re: Some codes refer slot()->{'slot_name'} but it is not defined
Fujii Masao <masao.fujii@oss.nttdata.com>
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>,
"'pgsql-hackers@lists.postgresql.org'" <pgsql-hackers@lists.postgresql.org>
Date: 2025-04-03T14:36:14Z
Lists: pgsql-hackers
On 2025/04/03 21:23, Hayato Kuroda (Fujitsu) wrote:
> Dear Fujii-san,
>
>> -is($node_primary->slot('dropme_slot')->{'slot_name'},
>> - undef, 'logical slot was actually dropped on standby');
>> +is($node_primary->slot('dropme_slot')->{'plugin'},
>> + '', 'logical slot was actually dropped on standby');
>>
>> This seems like a separate issue from what your patch is addressing,
>> but since this test is meant to confirm that the slot was dropped
>> on the standby, shouldn't node_primary be node_replica instead?
>
> You are right. It has been missed 8 years ago, let's fix now.
Thanks for the patch!
> BTW, the issue exists for all supported branches. How do you feel
> to backpatch them? PSA all patch set.
I think this fix should be backpatched to all supported versions.
Since the issue you found and the one I found seem different,
I'd prefer committing them separately. If that works for you,
here are the commit log messages I'm considering.
--------------------------------------
Fix logical decoding regression tests to correctly check slot existence.
The regression tests for logical decoding verify whether a logical slot
exists or has been dropped. Previously, these tests attempted to
retrieve "slot_name" from the result of slot(), but since "slot_name" was
not included in the result, slot()->{'slot_name'} always returned undef,
leading to incorrect behavior.
This commit fixes the issue by checking the "plugin" field in the result
of slot() instead, ensuring the tests properly verify slot existence.
Back-patch to all supported versions.
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/OSCPR01MB149667EC4E738769CA80B7EA5F5AE2@OSCPR01MB14966.jpnprd01.prod.outlook.com
Backpatch-through: 13
--------------------------------------
--------------------------------------
Fix logical decoding test to correctly check slot removal on standby.
The regression test for logical decoding verifies whether a logical slot
is correctly dropped on a standby when its associated database is dropped.
However, the test mistakenly retrieved slot information from the primary
instead of the standby, causing incorrect behavior.
This commit fixes the issue by ensuring the test correctly checks the slot
on the standby.
Back-patch to all supported versions.
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/1fdfd020-a509-403c-bd8f-a04664aba148@oss.nttdata.com
Backpatch-through: 13
--------------------------------------
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Commits
-
Fix logical decoding test to correctly check slot removal on standby.
- a11a823aa863 13.21 landed
- d4fe7437e536 14.18 landed
- 7b565bad85b7 15.13 landed
- 65e9418abe39 16.9 landed
- aab422af95c3 17.5 landed
- d5d85f188161 18.0 landed
-
Fix logical decoding regression tests to correctly check slot existence.
- b29a183c67e1 13.21 landed
- 0d22daad7e1a 14.18 landed
- 84fe9f1eb311 15.13 landed
- bc485fce52eb 16.9 landed
- 5570e103bf84 17.5 landed
- c754bdd8a2e5 18.0 landed