Logical decoding timeline following fails to handle records split across segments

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Álvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Subject: Logical decoding timeline following fails to handle records split across segments
Date: 2016-05-03 14:03:50
Message-ID: CAMsr+YG_1FU_-L8QWSk6oKFT4Jt8dpORy2RHXDyMy0B5ZfkpGA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all

There's a bug (mine) in logical decoding timeline following where reading
the first page from the segment containing a timeline switch fails to read
from the most recent timeline in that segment. This is harmless if the old
timeline's copy of the segment is present - but if it's been renamed to
.partial, deleted or never copied over to a replica then decoding will
complain that the required segment has already been removed. Just like
without timeline following.

The underlying problem is that timeline calculations used the record's
start pointer and didn't properly consider continuations; they were
record-based, not page-based like they should be.

A corrected and handily much, much simpler patch is attached. The logic for
finding the last timeline on a segment was massively more complex than it
needed to be, and that wasn't the only thing.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
0001-Rewrite-timeline-following-for-logical-decoding.patch text/x-patch 12.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2016-05-03 14:10:01 Re: pg9.6 segfault using simple query (related to use fk for join estimates)
Previous Message Masahiko Sawada 2016-05-03 13:57:51 Re: Reviewing freeze map code