pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Don't leave behind junk nbtree pages during split. 2+ messages / 1 participants [nested] [flat]
* pgsql: Don't leave behind junk nbtree pages during split. @ 2019-05-13 17:28 Peter Geoghegan <pg@bowt.ie> 0 siblings, 0 replies; 2+ messages in thread From: Peter Geoghegan @ 2019-05-13 17:28 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Don't leave behind junk nbtree pages during split. Commit 8fa30f906be reduced the elevel of a number of "can't happen" _bt_split() errors from PANIC to ERROR. At the same time, the new right page buffer for the split could continue to be acquired well before the critical section. This was possible because it was relatively straightforward to make sure that _bt_split() could not throw an error, with a few specific exceptions. The exceptional cases were safe because they involved specific, well understood errors, making it possible to consistently zero the right page before actually raising an error using elog(). There was no danger of leaving around a junk page, provided _bt_split() stuck to this coding rule. Commit 8224de4f, which introduced INCLUDE indexes, added code to make _bt_split() truncate away non-key attributes. This happened at a point that broke the rule around zeroing the right page in _bt_split(). If truncation failed (perhaps due to palloc() failure), that would result in an errant right page buffer with junk contents. This could confuse VACUUM when it attempted to delete the page, and should be avoided on general principle. To fix, reorganize _bt_split() so that truncation occurs before the new right page buffer is even acquired. A junk page/buffer will not be left behind if _bt_nonkey_truncate()/_bt_truncate() raise an error. Discussion: https://postgr.es/m/CAH2-WzkcWT_-NH7EeL=Az4efg0KCV+wArygW8zKB=+HoP=VWMw@mail.gmail.com Backpatch: 11-, where INCLUDE indexes were introduced. Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/9b42e713761a43e9ade3965285f077e2ba25bbb7 Modified Files -------------- src/backend/access/nbtree/nbtinsert.c | 213 ++++++++++++++++++++-------------- 1 file changed, 126 insertions(+), 87 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Don't leave behind junk nbtree pages during split. @ 2019-05-13 17:28 Peter Geoghegan <pg@bowt.ie> 0 siblings, 0 replies; 2+ messages in thread From: Peter Geoghegan @ 2019-05-13 17:28 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Don't leave behind junk nbtree pages during split. Commit 8fa30f906be reduced the elevel of a number of "can't happen" _bt_split() errors from PANIC to ERROR. At the same time, the new right page buffer for the split could continue to be acquired well before the critical section. This was possible because it was relatively straightforward to make sure that _bt_split() could not throw an error, with a few specific exceptions. The exceptional cases were safe because they involved specific, well understood errors, making it possible to consistently zero the right page before actually raising an error using elog(). There was no danger of leaving around a junk page, provided _bt_split() stuck to this coding rule. Commit 8224de4f, which introduced INCLUDE indexes, added code to make _bt_split() truncate away non-key attributes. This happened at a point that broke the rule around zeroing the right page in _bt_split(). If truncation failed (perhaps due to palloc() failure), that would result in an errant right page buffer with junk contents. This could confuse VACUUM when it attempted to delete the page, and should be avoided on general principle. To fix, reorganize _bt_split() so that truncation occurs before the new right page buffer is even acquired. A junk page/buffer will not be left behind if _bt_nonkey_truncate()/_bt_truncate() raise an error. Discussion: https://postgr.es/m/CAH2-WzkcWT_-NH7EeL=Az4efg0KCV+wArygW8zKB=+HoP=VWMw@mail.gmail.com Backpatch: 11-, where INCLUDE indexes were introduced. Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/bf78f50bae0b3b5ffcbf3e3c5b03fd138be15f9a Modified Files -------------- src/backend/access/nbtree/nbtinsert.c | 207 ++++++++++++++++++++-------------- 1 file changed, 123 insertions(+), 84 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2019-05-13 17:28 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-05-13 17:28 pgsql: Don't leave behind junk nbtree pages during split. Peter Geoghegan <pg@bowt.ie> 2019-05-13 17:28 pgsql: Don't leave behind junk nbtree pages during split. Peter Geoghegan <pg@bowt.ie>
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