pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14228: replication slot catalog_xmin not cleared on slot reuse
13+ messages / 5 participants
[nested] [flat]
* BUG #14228: replication slot catalog_xmin not cleared on slot reuse
@ 2016-07-05 17:35 andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
0 siblings, 1 reply; 13+ messages in thread
From: andrew@tao11.riddles.org.uk @ 2016-07-05 17:35 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 14228
Logged by: Andrew Gierth
Email address: andrew@tao11.riddles.org.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)
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
@ 2016-07-06 02:08 ` Michael Paquier <michael.paquier@gmail.com>
2016-07-06 03:56 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
0 siblings, 1 reply; 13+ messages in thread
From: Michael Paquier @ 2016-07-06 02:08 UTC (permalink / raw)
To: andrew@tao11.riddles.org.uk; +Cc: pgsql-bugs
On Wed, Jul 6, 2016 at 2:35 AM, <andrew@tao11.riddles.org.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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
fix-repslot-init.patch (text/x-diff, 774B) download
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index 2fb7c17..79b9331 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -274,10 +274,12 @@ ReplicationSlotCreate(const char *name, bool db_specific,
Assert(slot->active_pid == 0);
slot->data.persistency = persistency;
slot->data.xmin = InvalidTransactionId;
+ slot->data.catalog_xmin = InvalidTransactionId;
slot->effective_xmin = InvalidTransactionId;
StrNCpy(NameStr(slot->data.name), name, NAMEDATALEN);
slot->data.database = db_specific ? MyDatabaseId : InvalidOid;
slot->data.restart_lsn = InvalidXLogRecPtr;
+ slot->data.confirmed_flush = InvalidXLogRecPtr;
/*
* Create the slot on disk. We haven't actually marked the slot allocated
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
@ 2016-07-06 03:56 ` Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-07-06 04:07 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
0 siblings, 1 reply; 13+ messages in thread
From: Andrew Gierth @ 2016-07-06 03:56 UTC (permalink / raw)
To: Michael Paquier <michael.paquier@gmail.com>; +Cc: pgsql-bugs
>>>>> "Michael" == Michael Paquier <michael.paquier@gmail.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)
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-06 03:56 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
@ 2016-07-06 04:07 ` Michael Paquier <michael.paquier@gmail.com>
2016-07-25 15:25 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Stephen Frost <sfrost@snowman.net>
2016-07-28 00:24 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andres Freund <andres@anarazel.de>
0 siblings, 2 replies; 13+ messages in thread
From: Michael Paquier @ 2016-07-06 04:07 UTC (permalink / raw)
To: Andrew Gierth <andrew@tao11.riddles.org.uk>; +Cc: pgsql-bugs
_
On Wed, Jul 6, 2016 at 12:56 PM, Andrew Gierth
<andrew@tao11.riddles.org.uk> wrote:
>>>>>> "Michael" == Michael Paquier <michael.paquier@gmail.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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
fix-repslot-init-v2.patch (application/x-patch, 1.0K) download
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index 2fb7c17..6100e51 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -274,10 +274,17 @@ ReplicationSlotCreate(const char *name, bool db_specific,
Assert(slot->active_pid == 0);
slot->data.persistency = persistency;
slot->data.xmin = InvalidTransactionId;
+ slot->data.catalog_xmin = InvalidTransactionId;
slot->effective_xmin = InvalidTransactionId;
+ slot->effective_catalog_xmin = InvalidTransactionId;
+ slot->candidate_catalog_xmin = InvalidTransactionId;
+ slot->candidate_xmin_lsn = InvalidXLogRecPtr;
+ slot->candidate_restart_lsn = InvalidXLogRecPtr;
+ slot->candidate_restart_valid = InvalidXLogRecPtr;
StrNCpy(NameStr(slot->data.name), name, NAMEDATALEN);
slot->data.database = db_specific ? MyDatabaseId : InvalidOid;
slot->data.restart_lsn = InvalidXLogRecPtr;
+ slot->data.confirmed_flush = InvalidXLogRecPtr;
/*
* Create the slot on disk. We haven't actually marked the slot allocated
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-06 03:56 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-07-06 04:07 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
@ 2016-07-25 15:25 ` Stephen Frost <sfrost@snowman.net>
2016-07-26 00:58 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-08-09 13:30 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
1 sibling, 2 replies; 13+ messages in thread
From: Stephen Frost @ 2016-07-25 15:25 UTC (permalink / raw)
To: Michael Paquier <michael.paquier@gmail.com>; +Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-bugs
* Michael Paquier (michael.paquier@gmail.com) wrote:
> On Wed, Jul 6, 2016 at 12:56 PM, Andrew Gierth
> <andrew@tao11.riddles.org.uk> wrote:
> >>>>>> "Michael" == Michael Paquier <michael.paquier@gmail.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
Attachments:
signature.asc (application/pgp-signature, 818B) download
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-06 03:56 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-07-06 04:07 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-25 15:25 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Stephen Frost <sfrost@snowman.net>
@ 2016-07-26 00:58 ` Michael Paquier <michael.paquier@gmail.com>
1 sibling, 0 replies; 13+ messages in thread
From: Michael Paquier @ 2016-07-26 00:58 UTC (permalink / raw)
To: Stephen Frost <sfrost@snowman.net>; +Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-bugs; Andres Freund <andres@anarazel.de>; Robert Haas <robertmhaas@gmail.com>
On Tue, Jul 26, 2016 at 12:25 AM, Stephen Frost <sfrost@snowman.net> wrote:
> * Michael Paquier (michael.paquier@gmail.com) wrote:
>> On Wed, Jul 6, 2016 at 12:56 PM, Andrew Gierth
>> <andrew@tao11.riddles.org.uk> wrote:
>> >>>>>> "Michael" == Michael Paquier <michael.paquier@gmail.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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-06 03:56 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-07-06 04:07 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-25 15:25 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Stephen Frost <sfrost@snowman.net>
@ 2016-08-09 13:30 ` Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-08-09 23:03 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-08-15 01:03 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andres Freund <andres@anarazel.de>
1 sibling, 2 replies; 13+ messages in thread
From: Andrew Gierth @ 2016-08-09 13:30 UTC (permalink / raw)
To: Stephen Frost <sfrost@snowman.net>; +Cc: Michael Paquier <michael.paquier@gmail.com>; pgsql-bugs
>>>>> "Stephen" == Stephen Frost <sfrost@snowman.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)
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-06 03:56 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-07-06 04:07 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-25 15:25 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Stephen Frost <sfrost@snowman.net>
2016-08-09 13:30 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
@ 2016-08-09 23:03 ` Michael Paquier <michael.paquier@gmail.com>
1 sibling, 0 replies; 13+ messages in thread
From: Michael Paquier @ 2016-08-09 23:03 UTC (permalink / raw)
To: Andrew Gierth <andrew@tao11.riddles.org.uk>; +Cc: Stephen Frost <sfrost@snowman.net>; pgsql-bugs
On Tue, Aug 9, 2016 at 10:30 PM, Andrew Gierth
<andrew@tao11.riddles.org.uk> wrote:
>>>>>> "Stephen" == Stephen Frost <sfrost@snowman.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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-06 03:56 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-07-06 04:07 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-25 15:25 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Stephen Frost <sfrost@snowman.net>
2016-08-09 13:30 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
@ 2016-08-15 01:03 ` Andres Freund <andres@anarazel.de>
2016-08-15 07:42 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
1 sibling, 1 reply; 13+ messages in thread
From: Andres Freund @ 2016-08-15 01:03 UTC (permalink / raw)
To: Andrew Gierth <andrew@tao11.riddles.org.uk>; +Cc: Stephen Frost <sfrost@snowman.net>; Michael Paquier <michael.paquier@gmail.com>; pgsql-bugs
On 2016-08-09 14:30:58 +0100, Andrew Gierth wrote:
> >>>>> "Stephen" == Stephen Frost <sfrost@snowman.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.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-06 03:56 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-07-06 04:07 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-25 15:25 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Stephen Frost <sfrost@snowman.net>
2016-08-09 13:30 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-08-15 01:03 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andres Freund <andres@anarazel.de>
@ 2016-08-15 07:42 ` Michael Paquier <michael.paquier@gmail.com>
0 siblings, 0 replies; 13+ messages in thread
From: Michael Paquier @ 2016-08-15 07:42 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; Stephen Frost <sfrost@snowman.net>; pgsql-bugs
On Mon, Aug 15, 2016 at 10:03 AM, Andres Freund <andres@anarazel.de> wrote:
> On 2016-08-09 14:30:58 +0100, Andrew Gierth wrote:
>> >>>>> "Stephen" == Stephen Frost <sfrost@snowman.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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-06 03:56 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-07-06 04:07 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
@ 2016-07-28 00:24 ` Andres Freund <andres@anarazel.de>
2016-07-28 05:22 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
1 sibling, 1 reply; 13+ messages in thread
From: Andres Freund @ 2016-07-28 00:24 UTC (permalink / raw)
To: Michael Paquier <michael.paquier@gmail.com>; +Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; 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@tao11.riddles.org.uk> wrote:
> >>>>>> "Michael" == Michael Paquier <michael.paquier@gmail.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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-06 03:56 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-07-06 04:07 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-28 00:24 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andres Freund <andres@anarazel.de>
@ 2016-07-28 05:22 ` Michael Paquier <michael.paquier@gmail.com>
2016-08-17 20:23 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andres Freund <andres@anarazel.de>
0 siblings, 1 reply; 13+ messages in thread
From: Michael Paquier @ 2016-07-28 05:22 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; pgsql-bugs
On Thu, Jul 28, 2016 at 9:24 AM, Andres Freund <andres@anarazel.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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
fix-repslot-init-v3.patch (application/x-patch, 1.1K) download
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index 2fb7c17..c0b89ec 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -272,12 +272,20 @@ ReplicationSlotCreate(const char *name, bool db_specific,
*/
Assert(!slot->in_use);
Assert(slot->active_pid == 0);
+ memset(&slot->data, 0, sizeof(ReplicationSlotPersistentData));
slot->data.persistency = persistency;
slot->data.xmin = InvalidTransactionId;
+ slot->data.catalog_xmin = InvalidTransactionId;
slot->effective_xmin = InvalidTransactionId;
+ slot->effective_catalog_xmin = InvalidTransactionId;
+ slot->candidate_catalog_xmin = InvalidTransactionId;
+ slot->candidate_xmin_lsn = InvalidXLogRecPtr;
+ slot->candidate_restart_lsn = InvalidXLogRecPtr;
+ slot->candidate_restart_valid = InvalidXLogRecPtr;
StrNCpy(NameStr(slot->data.name), name, NAMEDATALEN);
slot->data.database = db_specific ? MyDatabaseId : InvalidOid;
slot->data.restart_lsn = InvalidXLogRecPtr;
+ slot->data.confirmed_flush = InvalidXLogRecPtr;
/*
* Create the slot on disk. We haven't actually marked the slot allocated
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-06 03:56 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-07-06 04:07 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
2016-07-28 00:24 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Andres Freund <andres@anarazel.de>
2016-07-28 05:22 ` Re: BUG #14228: replication slot catalog_xmin not cleared on slot reuse Michael Paquier <michael.paquier@gmail.com>
@ 2016-08-17 20:23 ` Andres Freund <andres@anarazel.de>
0 siblings, 0 replies; 13+ messages in thread
From: Andres Freund @ 2016-08-17 20:23 UTC (permalink / raw)
To: Michael Paquier <michael.paquier@gmail.com>; +Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>; 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@anarazel.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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
end of thread, other threads:[~2016-08-17 20:23 UTC | newest]
Thread overview: 13+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-07-05 17:35 BUG #14228: replication slot catalog_xmin not cleared on slot reuse andrew@tao11.riddles.org.uk
2016-07-06 02:08 ` Michael Paquier <michael.paquier@gmail.com>
2016-07-06 03:56 ` Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-07-06 04:07 ` Michael Paquier <michael.paquier@gmail.com>
2016-07-25 15:25 ` Stephen Frost <sfrost@snowman.net>
2016-07-26 00:58 ` Michael Paquier <michael.paquier@gmail.com>
2016-08-09 13:30 ` Andrew Gierth <andrew@tao11.riddles.org.uk>
2016-08-09 23:03 ` Michael Paquier <michael.paquier@gmail.com>
2016-08-15 01:03 ` Andres Freund <andres@anarazel.de>
2016-08-15 07:42 ` Michael Paquier <michael.paquier@gmail.com>
2016-07-28 00:24 ` Andres Freund <andres@anarazel.de>
2016-07-28 05:22 ` Michael Paquier <michael.paquier@gmail.com>
2016-08-17 20:23 ` Andres Freund <andres@anarazel.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox