pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix handling of all-zero pages in SP-GiST vacuum.
7+ messages / 3 participants
[nested] [flat]

* pgsql: Fix handling of all-zero pages in SP-GiST vacuum.
@ 2015-07-27 15:15 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  2015-07-27 15:36 ` Re: pgsql: Fix handling of all-zero pages in SP-GiST vacuum. Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 7+ messages in thread

From: Heikki Linnakangas @ 2015-07-27 15:15 UTC (permalink / raw)
  To: pgsql-committers

Fix handling of all-zero pages in SP-GiST vacuum.

SP-GiST initialized an all-zeros page at vacuum, but that was not
WAL-logged, which is not safe. You might get a torn page write, when it gets
flushed to disk, and end-up with a half-initialized index page. To fix,
leave it in the all-zeros state, and add it to the FSM. It will be
initialized when reused. Also don't set the page-deleted flag when recycling
an empty page. That was also not WAL-logged, and a torn write of that would
cause the page to have an invalid checksum.

Backpatch to 9.2, where SP-GiST indexes were added.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/023430abf72eb7d335430e241065d5ed19ddd94b

Modified Files
--------------
src/backend/access/spgist/spgvacuum.c |   27 ++++++++-------------------
src/include/access/spgist_private.h   |    4 ++--
2 files changed, 10 insertions(+), 21 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: pgsql: Fix handling of all-zero pages in SP-GiST vacuum.
  2015-07-27 15:15 pgsql: Fix handling of all-zero pages in SP-GiST vacuum. Heikki Linnakangas <heikki.linnakangas@iki.fi>
@ 2015-07-27 15:36 ` Tom Lane <tgl@sss.pgh.pa.us>
  2015-07-27 15:55   ` Re: pgsql: Fix handling of all-zero pages in SP-GiST vacuum. Heikki Linnakangas <hlinnaka@iki.fi>
  0 siblings, 1 reply; 7+ messages in thread

From: Tom Lane @ 2015-07-27 15:36 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@iki.fi>; +Cc: pgsql-committers

Heikki Linnakangas <heikki.linnakangas@iki.fi> writes:
> Fix handling of all-zero pages in SP-GiST vacuum.

I'm a little bit uncomfortable with the way that this patch presumes that
PageIsEmpty (a) is safe on an all-zeroes page and (b) will return true for
such a page.  Yes, it does work at the moment; but I don't think we are
making such an assumption anyplace else, and in view of your other two
concurrent patches, it doesn't seem very future-proof here either.
I recommend that the code look more like

    if (!SpGistBlockIsRoot(blkno))
    {
        if (PageIsNew(page) || PageIsEmpty(page))


			regards, tom lane


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: pgsql: Fix handling of all-zero pages in SP-GiST vacuum.
  2015-07-27 15:15 pgsql: Fix handling of all-zero pages in SP-GiST vacuum. Heikki Linnakangas <heikki.linnakangas@iki.fi>
  2015-07-27 15:36 ` Re: pgsql: Fix handling of all-zero pages in SP-GiST vacuum. Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-07-27 15:55   ` Heikki Linnakangas <hlinnaka@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2015-07-27 15:55 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers

On 07/27/2015 06:36 PM, Tom Lane wrote:
> Heikki Linnakangas <heikki.linnakangas@iki.fi> writes:
>> Fix handling of all-zero pages in SP-GiST vacuum.
>
> I'm a little bit uncomfortable with the way that this patch presumes that
> PageIsEmpty (a) is safe on an all-zeroes page and (b) will return true for
> such a page.  Yes, it does work at the moment; but I don't think we are
> making such an assumption anyplace else, and in view of your other two
> concurrent patches, it doesn't seem very future-proof here either.
> I recommend that the code look more like
>
>      if (!SpGistBlockIsRoot(blkno))
>      {
>          if (PageIsNew(page) || PageIsEmpty(page))
>

I thought I saw other places that assumed that, and I even thought I saw 
a comment somewhere documenting that usage. But now that I grep around, 
I see no such thing.

I'll go change that...

- Heikki



-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix handling of all-zero pages in SP-GiST vacuum.
@ 2015-07-27 15:15 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2015-07-27 15:15 UTC (permalink / raw)
  To: pgsql-committers

Fix handling of all-zero pages in SP-GiST vacuum.

SP-GiST initialized an all-zeros page at vacuum, but that was not
WAL-logged, which is not safe. You might get a torn page write, when it gets
flushed to disk, and end-up with a half-initialized index page. To fix,
leave it in the all-zeros state, and add it to the FSM. It will be
initialized when reused. Also don't set the page-deleted flag when recycling
an empty page. That was also not WAL-logged, and a torn write of that would
cause the page to have an invalid checksum.

Backpatch to 9.2, where SP-GiST indexes were added.

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/2fa8ba34804211714a6e0a7fcf5512423c77f8dd

Modified Files
--------------
src/backend/access/spgist/spgvacuum.c |   27 ++++++++-------------------
src/include/access/spgist_private.h   |    4 ++--
2 files changed, 10 insertions(+), 21 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix handling of all-zero pages in SP-GiST vacuum.
@ 2015-07-27 15:15 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2015-07-27 15:15 UTC (permalink / raw)
  To: pgsql-committers

Fix handling of all-zero pages in SP-GiST vacuum.

SP-GiST initialized an all-zeros page at vacuum, but that was not
WAL-logged, which is not safe. You might get a torn page write, when it gets
flushed to disk, and end-up with a half-initialized index page. To fix,
leave it in the all-zeros state, and add it to the FSM. It will be
initialized when reused. Also don't set the page-deleted flag when recycling
an empty page. That was also not WAL-logged, and a torn write of that would
cause the page to have an invalid checksum.

Backpatch to 9.2, where SP-GiST indexes were added.

Branch
------
REL9_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/579b9f97ce99c3ddc8e1de0e1b1f160da2e669c7

Modified Files
--------------
src/backend/access/spgist/spgvacuum.c |   27 ++++++++-------------------
src/include/access/spgist_private.h   |    4 ++--
2 files changed, 10 insertions(+), 21 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix handling of all-zero pages in SP-GiST vacuum.
@ 2015-07-27 15:15 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2015-07-27 15:15 UTC (permalink / raw)
  To: pgsql-committers

Fix handling of all-zero pages in SP-GiST vacuum.

SP-GiST initialized an all-zeros page at vacuum, but that was not
WAL-logged, which is not safe. You might get a torn page write, when it gets
flushed to disk, and end-up with a half-initialized index page. To fix,
leave it in the all-zeros state, and add it to the FSM. It will be
initialized when reused. Also don't set the page-deleted flag when recycling
an empty page. That was also not WAL-logged, and a torn write of that would
cause the page to have an invalid checksum.

Backpatch to 9.2, where SP-GiST indexes were added.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/863af3a3797a3a8ca19c9bdd57c5f5b538e04e22

Modified Files
--------------
src/backend/access/spgist/spgvacuum.c |   27 ++++++++-------------------
src/include/access/spgist_private.h   |    4 ++--
2 files changed, 10 insertions(+), 21 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix handling of all-zero pages in SP-GiST vacuum.
@ 2015-07-27 15:15 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2015-07-27 15:15 UTC (permalink / raw)
  To: pgsql-committers

Fix handling of all-zero pages in SP-GiST vacuum.

SP-GiST initialized an all-zeros page at vacuum, but that was not
WAL-logged, which is not safe. You might get a torn page write, when it gets
flushed to disk, and end-up with a half-initialized index page. To fix,
leave it in the all-zeros state, and add it to the FSM. It will be
initialized when reused. Also don't set the page-deleted flag when recycling
an empty page. That was also not WAL-logged, and a torn write of that would
cause the page to have an invalid checksum.

Backpatch to 9.2, where SP-GiST indexes were added.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/f4297f8c5fd457a54671947023f8b56237b952db

Modified Files
--------------
src/backend/access/spgist/spgvacuum.c |   27 ++++++++-------------------
src/include/access/spgist_private.h   |    4 ++--
2 files changed, 10 insertions(+), 21 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2015-07-27 15:55 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-07-27 15:15 pgsql: Fix handling of all-zero pages in SP-GiST vacuum. Heikki Linnakangas <heikki.linnakangas@iki.fi>
2015-07-27 15:36 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-07-27 15:55   ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 15:15 pgsql: Fix handling of all-zero pages in SP-GiST vacuum. Heikki Linnakangas <heikki.linnakangas@iki.fi>
2015-07-27 15:15 pgsql: Fix handling of all-zero pages in SP-GiST vacuum. Heikki Linnakangas <heikki.linnakangas@iki.fi>
2015-07-27 15:15 pgsql: Fix handling of all-zero pages in SP-GiST vacuum. Heikki Linnakangas <heikki.linnakangas@iki.fi>
2015-07-27 15:15 pgsql: Fix handling of all-zero pages in SP-GiST vacuum. Heikki Linnakangas <heikki.linnakangas@iki.fi>

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