Re: Bug in gin insert redo code path during re-compression of empty gin data leaf pages

From: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
To: sivasubr(at)amazon(dot)com
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug in gin insert redo code path during re-compression of empty gin data leaf pages
Date: 2018-07-18 08:59:02
Message-ID: CAPpHfdu9p8fpNsBCcdYxhBpXhe2_g3CDKjTKhh5BCEDuz6JdiA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

On Wed, Jul 18, 2018 at 1:40 AM R, Siva <sivasubr(at)amazon(dot)com> wrote:

> We came across an issue during replay of a gin insert record on a pre-9.4
> uncompressed data leaf page that does not have any items in it. The engine
> version where the replay is done is 9.6.3. The redo logic attempts to
> compress the existing page items before trying to insert new items from
> the WAL record[1]. In this particular case, we noticed that if the data
> leaf page does not have any items in it (see below on how such a page can
> be present), the compression should not be attempted as the algorithm
> expects the page to have at least one item [2]. This will lead to incorrect
> data size set on the page and also makes the assertion that expects npacked
> and nuncompressed to be equal, false [3].
>
> In Postgres 9.3, when the gin posting tree is vacuumed, the pages that are
> in the leftmost and rightmost branches are not deleted [4]. These empty
> pages can be part of the database after upgrading to 9.6.3. We verified
> this by doing the following test:
>

Thank you for reporting this bug. At the first glance it seems that your
proposed fix is correct. I'll review it in more details and commit.

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2018-07-18 08:59:52 Re: why partition pruning doesn't work?
Previous Message Tsunakawa, Takayuki 2018-07-18 08:38:38 RE: [bug fix] Produce a crash dump before main() on Windows