| Lists: | pgsql-bugs |
|---|
| From: | andrew(at)tao11(dot)riddles(dot)org(dot)uk |
|---|---|
| To: | pgsql-bugs(at)postgresql(dot)org |
| Subject: | BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-07-05 17:35:02 |
| Message-ID: | 20160705173502.1398.70934@wrigleys.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 14228
Logged by: Andrew Gierth
Email address: andrew(at)tao11(dot)riddles(dot)org(dot)uk
PostgreSQL version: 9.6beta2
Operating system: any
Description:
[My analysis of a bug reported on IRC; please CC original reporter: md at
chewy dot com]
Reported on pg 9.4.6 but also reproduced on 9.6beta2
When creating a physical replication slot, the catalog_xmin field of the new
slot is not initialized. If the slot storage had previously been used for a
logical slot, the old catalog_xmin will remain in place and interfere with
vacuum.
Trivially reproducible:
select pg_create_logical_replication_slot('test','test_decoding');
select pg_drop_replication_slot('test');
select pg_create_physical_replication_slot('test');
select * from pg_replication_slots;
slot_name | plugin | slot_type | datoid | database | active | active_pid |
xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn
-----------+--------+-----------+--------+----------+--------+------------+------+--------------+-------------+---------------------
test | | physical | | | f | |
| 546 | | 0/1525438
(1 row)
| From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
|---|---|
| To: | andrew(at)tao11(dot)riddles(dot)org(dot)uk |
| Cc: | PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-07-06 02:08:35 |
| Message-ID: | CAB7nPqQ6WWipoN3A3g-uWQM=JJcGWSKA8Bw-q3+jXOiuNd-iRw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
On Wed, Jul 6, 2016 at 2:35 AM, <andrew(at)tao11(dot)riddles(dot)org(dot)uk> wrote:
> When creating a physical replication slot, the catalog_xmin field of the new
> slot is not initialized. If the slot storage had previously been used for a
> logical slot, the old catalog_xmin will remain in place and interfere with
> vacuum.
Good catch! The same applies to confirmed_flush_lsn, which is used
only by logical decoding and should remain as NULL for physical slots.
So I propose the patch attached to address both problems.
--
Michael
| Attachment | Content-Type | Size |
|---|---|---|
| fix-repslot-init.patch | text/x-diff | 774 bytes |
| From: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
|---|---|
| To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
| Cc: | PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-07-06 03:56:31 |
| Message-ID: | 87vb0ja0b5.fsf@news-spur.riddles.org.uk |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
>>>>> "Michael" == Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
>> When creating a physical replication slot, the catalog_xmin field of
>> the new slot is not initialized. If the slot storage had previously
>> been used for a logical slot, the old catalog_xmin will remain in
>> place and interfere with vacuum.
Michael> Good catch! The same applies to confirmed_flush_lsn, which is
Michael> used only by logical decoding and should remain as NULL for
Michael> physical slots. So I propose the patch attached to address
Michael> both problems.
What about slot->effective_catalog_xmin ?
--
Andrew (irc:RhodiumToad)
| From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
|---|---|
| To: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
| Cc: | PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-07-06 04:07:36 |
| Message-ID: | CAB7nPqTQTRi0JmRUX_j=3rt0+kBPAW7EKPQRWoyjGwid98hZ+w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
_
On Wed, Jul 6, 2016 at 12:56 PM, Andrew Gierth
<andrew(at)tao11(dot)riddles(dot)org(dot)uk> wrote:
>>>>>> "Michael" == Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
>
> >> When creating a physical replication slot, the catalog_xmin field of
> >> the new slot is not initialized. If the slot storage had previously
> >> been used for a logical slot, the old catalog_xmin will remain in
> >> place and interfere with vacuum.
>
> Michael> Good catch! The same applies to confirmed_flush_lsn, which is
> Michael> used only by logical decoding and should remain as NULL for
> Michael> physical slots. So I propose the patch attached to address
> Michael> both problems.
>
> What about slot->effective_catalog_xmin ?
Yes. I guess so, as well as the other candidate_* fields in the slot
to begin from a clean state.
--
Michael
| Attachment | Content-Type | Size |
|---|---|---|
| fix-repslot-init-v2.patch | application/x-patch | 1.0 KB |
| From: | Stephen Frost <sfrost(at)snowman(dot)net> |
|---|---|
| To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
| Cc: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-07-25 15:25:31 |
| Message-ID: | 20160725152531.GY4028@tamriel.snowman.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
* Michael Paquier (michael(dot)paquier(at)gmail(dot)com) wrote:
> On Wed, Jul 6, 2016 at 12:56 PM, Andrew Gierth
> <andrew(at)tao11(dot)riddles(dot)org(dot)uk> wrote:
> >>>>>> "Michael" == Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
> >
> > >> When creating a physical replication slot, the catalog_xmin field of
> > >> the new slot is not initialized. If the slot storage had previously
> > >> been used for a logical slot, the old catalog_xmin will remain in
> > >> place and interfere with vacuum.
> >
> > Michael> Good catch! The same applies to confirmed_flush_lsn, which is
> > Michael> used only by logical decoding and should remain as NULL for
> > Michael> physical slots. So I propose the patch attached to address
> > Michael> both problems.
> >
> > What about slot->effective_catalog_xmin ?
>
> Yes. I guess so, as well as the other candidate_* fields in the slot
> to begin from a clean state.
Seems like we should try to get this in before the next round of point
releases...?
Thanks!
Stephen
| From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
|---|---|
| To: | Stephen Frost <sfrost(at)snowman(dot)net> |
| Cc: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com> |
| Subject: | Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-07-26 00:58:49 |
| Message-ID: | CAB7nPqRLLa-4TiSs0viDOcNBqsx0f5KSHWQAFYF17um1CZHfGw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
On Tue, Jul 26, 2016 at 12:25 AM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
> * Michael Paquier (michael(dot)paquier(at)gmail(dot)com) wrote:
>> On Wed, Jul 6, 2016 at 12:56 PM, Andrew Gierth
>> <andrew(at)tao11(dot)riddles(dot)org(dot)uk> wrote:
>> >>>>>> "Michael" == Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
>> >
>> > >> When creating a physical replication slot, the catalog_xmin field of
>> > >> the new slot is not initialized. If the slot storage had previously
>> > >> been used for a logical slot, the old catalog_xmin will remain in
>> > >> place and interfere with vacuum.
>> >
>> > Michael> Good catch! The same applies to confirmed_flush_lsn, which is
>> > Michael> used only by logical decoding and should remain as NULL for
>> > Michael> physical slots. So I propose the patch attached to address
>> > Michael> both problems.
>> >
>> > What about slot->effective_catalog_xmin ?
>>
>> Yes. I guess so, as well as the other candidate_* fields in the slot
>> to begin from a clean state.
>
> Seems like we should try to get this in before the next round of point
> releases...?
That would be nice, I would guess that Andres or Robert (added in CC)
are the best fits to commit this patch, even if this is just a
variable initialization issue.
--
Michael
| From: | Andres Freund <andres(at)anarazel(dot)de> |
|---|---|
| To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
| Cc: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-07-28 00:24:37 |
| Message-ID: | 20160728002437.t4xvmdkgelwwsm75@alap3.anarazel.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
On 2016-07-06 13:07:36 +0900, Michael Paquier wrote:
> _
>
> On Wed, Jul 6, 2016 at 12:56 PM, Andrew Gierth
> <andrew(at)tao11(dot)riddles(dot)org(dot)uk> wrote:
> >>>>>> "Michael" == Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
> >
> > >> When creating a physical replication slot, the catalog_xmin field of
> > >> the new slot is not initialized. If the slot storage had previously
> > >> been used for a logical slot, the old catalog_xmin will remain in
> > >> place and interfere with vacuum.
> >
> > Michael> Good catch! The same applies to confirmed_flush_lsn, which is
> > Michael> used only by logical decoding and should remain as NULL for
> > Michael> physical slots. So I propose the patch attached to address
> > Michael> both problems.
> >
> > What about slot->effective_catalog_xmin ?
>
> Yes. I guess so, as well as the other candidate_* fields in the slot
> to begin from a clean state.
I think it'd be better if we explicitly zeroed .data - that way the
likelihood of future bugs of the same ilk is smaller.
Greetings,
Andres Freund
| From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
|---|---|
| To: | Andres Freund <andres(at)anarazel(dot)de> |
| Cc: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-07-28 05:22:29 |
| Message-ID: | CAB7nPqQXyffKzejuDwJymQBQAFrYzHgNthY79nRK+FFhm9Yw6Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
On Thu, Jul 28, 2016 at 9:24 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> I think it'd be better if we explicitly zeroed .data - that way the
> likelihood of future bugs of the same ilk is smaller.
Okay, I have spent some time looking at all the fields here, and their
significance before reaching this code path in ReplicationSlotCreate,
but did not find any hole if slot->data is zeroed. So here is an
updated patch. You could get rid of all the field initializations I
have done for slot->data, but I think that's cheap to keep them.
--
Michael
| Attachment | Content-Type | Size |
|---|---|---|
| fix-repslot-init-v3.patch | application/x-patch | 1.1 KB |
| From: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
|---|---|
| To: | Stephen Frost <sfrost(at)snowman(dot)net> |
| Cc: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-08-09 13:30:58 |
| Message-ID: | 87bn12ax6e.fsf@news-spur.riddles.org.uk |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
>>>>> "Stephen" == Stephen Frost <sfrost(at)snowman(dot)net> writes:
Stephen> Seems like we should try to get this in before the next round
Stephen> of point releases...?
I notice that this didn't happen....
--
Andrew (irc:RhodiumToad)
| From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
|---|---|
| To: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
| Cc: | Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-08-09 23:03:18 |
| Message-ID: | CAB7nPqQU-fxHW8knFxUZg1gobMeqi53002c+4_iSwESZti9-TA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
On Tue, Aug 9, 2016 at 10:30 PM, Andrew Gierth
<andrew(at)tao11(dot)riddles(dot)org(dot)uk> wrote:
>>>>>> "Stephen" == Stephen Frost <sfrost(at)snowman(dot)net> writes:
>
> Stephen> Seems like we should try to get this in before the next round
> Stephen> of point releases...?
>
> I notice that this didn't happen....
At this point I have added it to the next CF as a bug fix:
https://commitfest.postgresql.org/10/705/
--
Michael
| From: | Andres Freund <andres(at)anarazel(dot)de> |
|---|---|
| To: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
| Cc: | Stephen Frost <sfrost(at)snowman(dot)net>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-08-15 01:03:49 |
| Message-ID: | 20160815010349.wfhbnfilzpjvvm4h@alap3.anarazel.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
On 2016-08-09 14:30:58 +0100, Andrew Gierth wrote:
> >>>>> "Stephen" == Stephen Frost <sfrost(at)snowman(dot)net> writes:
>
> Stephen> Seems like we should try to get this in before the next round
> Stephen> of point releases...?
>
> I notice that this didn't happen....
I'll piuck it up when I'm back from holidays (Tuesday/Wednesday). Sorry
for the delay.
| From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
|---|---|
| To: | Andres Freund <andres(at)anarazel(dot)de> |
| Cc: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-08-15 07:42:14 |
| Message-ID: | CAB7nPqSahKcG0hysQYFMzQUMAjfTsc7+xSggr+g0Sism30JsaA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
On Mon, Aug 15, 2016 at 10:03 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> On 2016-08-09 14:30:58 +0100, Andrew Gierth wrote:
>> >>>>> "Stephen" == Stephen Frost <sfrost(at)snowman(dot)net> writes:
>>
>> Stephen> Seems like we should try to get this in before the next round
>> Stephen> of point releases...?
>>
>> I notice that this didn't happen....
>
> I'll piuck it up when I'm back from holidays (Tuesday/Wednesday). Sorry
> for the delay.
Thanks!
--
Michael
| From: | Andres Freund <andres(at)anarazel(dot)de> |
|---|---|
| To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
| Cc: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse |
| Date: | 2016-08-17 20:23:38 |
| Message-ID: | 20160817202338.gtdm25nq3zp4i4ul@alap3.anarazel.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-bugs |
On 2016-07-28 14:22:29 +0900, Michael Paquier wrote:
> On Thu, Jul 28, 2016 at 9:24 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> > I think it'd be better if we explicitly zeroed .data - that way the
> > likelihood of future bugs of the same ilk is smaller.
>
> Okay, I have spent some time looking at all the fields here, and their
> significance before reaching this code path in ReplicationSlotCreate,
> but did not find any hole if slot->data is zeroed. So here is an
> updated patch. You could get rid of all the field initializations I
> have done for slot->data, but I think that's cheap to keep them.
Pushed without the additional initializations - they're imo more
confusing than helpful - and with some more reordering to match the
struct order.
Regards,
Andres