pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Properly detoast data in brin_form_tuple
7+ messages / 1 participants
[nested] [flat]

* pgsql: Properly detoast data in brin_form_tuple
@ 2020-11-06 23:39 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Tomas Vondra @ 2020-11-06 23:39 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Properly detoast data in brin_form_tuple

brin_form_tuple failed to consider the values may be toasted, inserting
the toast pointer into the index. This may easily result in index
corruption, as the toast data may be deleted and cleaned up by vacuum.
The cleanup however does not care about indexes, leaving invalid toast
pointers behind, which triggers errors like this:

  ERROR:  missing chunk number 0 for toast value 16433 in pg_toast_16426

A less severe consequence are inconsistent failures due to the index row
being too large, depending on whether brin_form_tuple operated on plain
or toasted version of the row. For example

    CREATE TABLE t (val TEXT);
    INSERT INTO t VALUES ('... long value ...')
    CREATE INDEX idx ON t USING brin (val);

would likely succeed, as the row would likely include toast pointer.
Switching the order of INSERT and CREATE INDEX would likely fail:

    ERROR:  index row size 8712 exceeds maximum 8152 for index "idx"

because this happens before the row values are toasted.

The bug exists since PostgreSQL 9.5 where BRIN indexes were introduced.
So backpatch all the way back.

Author: Tomas Vondra
Reviewed-by: Alvaro Herrera
Backpatch-through: 9.5
Discussion: https://postgr.es/m/20201001184133.oq5uq75sb45pu3aw@development
Discussion: https://postgr.es/m/20201104010544.zexj52mlldagzowv%40development

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7577dd84807a808f295dbfb0191540750ff98002

Modified Files
--------------
src/backend/access/brin/brin_tuple.c | 102 ++++++++++++++++++++++++++++++++++-
src/test/regress/expected/brin.out   |  41 ++++++++++++++
src/test/regress/sql/brin.sql        |  39 ++++++++++++++
3 files changed, 181 insertions(+), 1 deletion(-)



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

* pgsql: Properly detoast data in brin_form_tuple
@ 2020-11-06 23:40 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Tomas Vondra @ 2020-11-06 23:40 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Properly detoast data in brin_form_tuple

brin_form_tuple failed to consider the values may be toasted, inserting
the toast pointer into the index. This may easily result in index
corruption, as the toast data may be deleted and cleaned up by vacuum.
The cleanup however does not care about indexes, leaving invalid toast
pointers behind, which triggers errors like this:

  ERROR:  missing chunk number 0 for toast value 16433 in pg_toast_16426

A less severe consequence are inconsistent failures due to the index row
being too large, depending on whether brin_form_tuple operated on plain
or toasted version of the row. For example

    CREATE TABLE t (val TEXT);
    INSERT INTO t VALUES ('... long value ...')
    CREATE INDEX idx ON t USING brin (val);

would likely succeed, as the row would likely include toast pointer.
Switching the order of INSERT and CREATE INDEX would likely fail:

    ERROR:  index row size 8712 exceeds maximum 8152 for index "idx"

because this happens before the row values are toasted.

The bug exists since PostgreSQL 9.5 where BRIN indexes were introduced.
So backpatch all the way back.

Author: Tomas Vondra
Reviewed-by: Alvaro Herrera
Backpatch-through: 9.5
Discussion: https://postgr.es/m/20201001184133.oq5uq75sb45pu3aw@development
Discussion: https://postgr.es/m/20201104010544.zexj52mlldagzowv%40development

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6a7b55f3716fad9c40ecb960cb7b7d616d5b02fd

Modified Files
--------------
src/backend/access/brin/brin_tuple.c | 102 ++++++++++++++++++++++++++++++++++-
src/test/regress/expected/brin.out   |  41 ++++++++++++++
src/test/regress/sql/brin.sql        |  39 ++++++++++++++
3 files changed, 181 insertions(+), 1 deletion(-)



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

* pgsql: Properly detoast data in brin_form_tuple
@ 2020-11-06 23:40 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Tomas Vondra @ 2020-11-06 23:40 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Properly detoast data in brin_form_tuple

brin_form_tuple failed to consider the values may be toasted, inserting
the toast pointer into the index. This may easily result in index
corruption, as the toast data may be deleted and cleaned up by vacuum.
The cleanup however does not care about indexes, leaving invalid toast
pointers behind, which triggers errors like this:

  ERROR:  missing chunk number 0 for toast value 16433 in pg_toast_16426

A less severe consequence are inconsistent failures due to the index row
being too large, depending on whether brin_form_tuple operated on plain
or toasted version of the row. For example

    CREATE TABLE t (val TEXT);
    INSERT INTO t VALUES ('... long value ...')
    CREATE INDEX idx ON t USING brin (val);

would likely succeed, as the row would likely include toast pointer.
Switching the order of INSERT and CREATE INDEX would likely fail:

    ERROR:  index row size 8712 exceeds maximum 8152 for index "idx"

because this happens before the row values are toasted.

The bug exists since PostgreSQL 9.5 where BRIN indexes were introduced.
So backpatch all the way back.

Author: Tomas Vondra
Reviewed-by: Alvaro Herrera
Backpatch-through: 9.5
Discussion: https://postgr.es/m/20201001184133.oq5uq75sb45pu3aw@development
Discussion: https://postgr.es/m/20201104010544.zexj52mlldagzowv%40development

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8149e9f9a0d684dce883d9e5a9f7380afbdbd7d6

Modified Files
--------------
src/backend/access/brin/brin_tuple.c | 91 +++++++++++++++++++++++++++++++++++-
src/test/regress/expected/brin.out   | 41 ++++++++++++++++
src/test/regress/sql/brin.sql        | 39 ++++++++++++++++
3 files changed, 170 insertions(+), 1 deletion(-)



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

* pgsql: Properly detoast data in brin_form_tuple
@ 2020-11-06 23:41 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Tomas Vondra @ 2020-11-06 23:41 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Properly detoast data in brin_form_tuple

brin_form_tuple failed to consider the values may be toasted, inserting
the toast pointer into the index. This may easily result in index
corruption, as the toast data may be deleted and cleaned up by vacuum.
The cleanup however does not care about indexes, leaving invalid toast
pointers behind, which triggers errors like this:

  ERROR:  missing chunk number 0 for toast value 16433 in pg_toast_16426

A less severe consequence are inconsistent failures due to the index row
being too large, depending on whether brin_form_tuple operated on plain
or toasted version of the row. For example

    CREATE TABLE t (val TEXT);
    INSERT INTO t VALUES ('... long value ...')
    CREATE INDEX idx ON t USING brin (val);

would likely succeed, as the row would likely include toast pointer.
Switching the order of INSERT and CREATE INDEX would likely fail:

    ERROR:  index row size 8712 exceeds maximum 8152 for index "idx"

because this happens before the row values are toasted.

The bug exists since PostgreSQL 9.5 where BRIN indexes were introduced.
So backpatch all the way back.

Author: Tomas Vondra
Reviewed-by: Alvaro Herrera
Backpatch-through: 9.5
Discussion: https://postgr.es/m/20201001184133.oq5uq75sb45pu3aw@development
Discussion: https://postgr.es/m/20201104010544.zexj52mlldagzowv%40development

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/895d0f0e821805e3f2b9eb848fc11ea5df77dbaf

Modified Files
--------------
src/backend/access/brin/brin_tuple.c | 91 +++++++++++++++++++++++++++++++++++-
src/test/regress/expected/brin.out   | 41 ++++++++++++++++
src/test/regress/sql/brin.sql        | 39 ++++++++++++++++
3 files changed, 170 insertions(+), 1 deletion(-)



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

* pgsql: Properly detoast data in brin_form_tuple
@ 2020-11-06 23:41 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Tomas Vondra @ 2020-11-06 23:41 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Properly detoast data in brin_form_tuple

brin_form_tuple failed to consider the values may be toasted, inserting
the toast pointer into the index. This may easily result in index
corruption, as the toast data may be deleted and cleaned up by vacuum.
The cleanup however does not care about indexes, leaving invalid toast
pointers behind, which triggers errors like this:

  ERROR:  missing chunk number 0 for toast value 16433 in pg_toast_16426

A less severe consequence are inconsistent failures due to the index row
being too large, depending on whether brin_form_tuple operated on plain
or toasted version of the row. For example

    CREATE TABLE t (val TEXT);
    INSERT INTO t VALUES ('... long value ...')
    CREATE INDEX idx ON t USING brin (val);

would likely succeed, as the row would likely include toast pointer.
Switching the order of INSERT and CREATE INDEX would likely fail:

    ERROR:  index row size 8712 exceeds maximum 8152 for index "idx"

because this happens before the row values are toasted.

The bug exists since PostgreSQL 9.5 where BRIN indexes were introduced.
So backpatch all the way back.

Author: Tomas Vondra
Reviewed-by: Alvaro Herrera
Backpatch-through: 9.5
Discussion: https://postgr.es/m/20201001184133.oq5uq75sb45pu3aw@development
Discussion: https://postgr.es/m/20201104010544.zexj52mlldagzowv%40development

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0b96fc977c5b387f0f8a980672f035b34cdf60b7

Modified Files
--------------
src/backend/access/brin/brin_tuple.c | 91 +++++++++++++++++++++++++++++++++++-
src/test/regress/expected/brin.out   | 41 ++++++++++++++++
src/test/regress/sql/brin.sql        | 39 ++++++++++++++++
3 files changed, 170 insertions(+), 1 deletion(-)



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

* pgsql: Properly detoast data in brin_form_tuple
@ 2020-11-06 23:41 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Tomas Vondra @ 2020-11-06 23:41 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Properly detoast data in brin_form_tuple

brin_form_tuple failed to consider the values may be toasted, inserting
the toast pointer into the index. This may easily result in index
corruption, as the toast data may be deleted and cleaned up by vacuum.
The cleanup however does not care about indexes, leaving invalid toast
pointers behind, which triggers errors like this:

  ERROR:  missing chunk number 0 for toast value 16433 in pg_toast_16426

A less severe consequence are inconsistent failures due to the index row
being too large, depending on whether brin_form_tuple operated on plain
or toasted version of the row. For example

    CREATE TABLE t (val TEXT);
    INSERT INTO t VALUES ('... long value ...')
    CREATE INDEX idx ON t USING brin (val);

would likely succeed, as the row would likely include toast pointer.
Switching the order of INSERT and CREATE INDEX would likely fail:

    ERROR:  index row size 8712 exceeds maximum 8152 for index "idx"

because this happens before the row values are toasted.

The bug exists since PostgreSQL 9.5 where BRIN indexes were introduced.
So backpatch all the way back.

Author: Tomas Vondra
Reviewed-by: Alvaro Herrera
Backpatch-through: 9.5
Discussion: https://postgr.es/m/20201001184133.oq5uq75sb45pu3aw@development
Discussion: https://postgr.es/m/20201104010544.zexj52mlldagzowv%40development

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bae31e75f7777f2398eccbd40c5676e3dd487d1a

Modified Files
--------------
src/backend/access/brin/brin_tuple.c | 91 +++++++++++++++++++++++++++++++++++-
src/test/regress/expected/brin.out   | 42 +++++++++++++++++
src/test/regress/sql/brin.sql        | 40 ++++++++++++++++
3 files changed, 172 insertions(+), 1 deletion(-)



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

* pgsql: Properly detoast data in brin_form_tuple
@ 2020-11-06 23:42 Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Tomas Vondra @ 2020-11-06 23:42 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Properly detoast data in brin_form_tuple

brin_form_tuple failed to consider the values may be toasted, inserting
the toast pointer into the index. This may easily result in index
corruption, as the toast data may be deleted and cleaned up by vacuum.
The cleanup however does not care about indexes, leaving invalid toast
pointers behind, which triggers errors like this:

  ERROR:  missing chunk number 0 for toast value 16433 in pg_toast_16426

A less severe consequence are inconsistent failures due to the index row
being too large, depending on whether brin_form_tuple operated on plain
or toasted version of the row. For example

    CREATE TABLE t (val TEXT);
    INSERT INTO t VALUES ('... long value ...')
    CREATE INDEX idx ON t USING brin (val);

would likely succeed, as the row would likely include toast pointer.
Switching the order of INSERT and CREATE INDEX would likely fail:

    ERROR:  index row size 8712 exceeds maximum 8152 for index "idx"

because this happens before the row values are toasted.

The bug exists since PostgreSQL 9.5 where BRIN indexes were introduced.
So backpatch all the way back.

Author: Tomas Vondra
Reviewed-by: Alvaro Herrera
Backpatch-through: 9.5
Discussion: https://postgr.es/m/20201001184133.oq5uq75sb45pu3aw@development
Discussion: https://postgr.es/m/20201104010544.zexj52mlldagzowv%40development

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d2d3a4bd33d2c0b1ffb1a4f6db6b866619134a4b

Modified Files
--------------
src/backend/access/brin/brin_tuple.c | 91 +++++++++++++++++++++++++++++++++++-
src/test/regress/expected/brin.out   | 42 +++++++++++++++++
src/test/regress/sql/brin.sql        | 40 ++++++++++++++++
3 files changed, 172 insertions(+), 1 deletion(-)



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


end of thread, other threads:[~2020-11-06 23:42 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06 23:39 pgsql: Properly detoast data in brin_form_tuple Tomas Vondra <tomas.vondra@postgresql.org>
2020-11-06 23:40 pgsql: Properly detoast data in brin_form_tuple Tomas Vondra <tomas.vondra@postgresql.org>
2020-11-06 23:40 pgsql: Properly detoast data in brin_form_tuple Tomas Vondra <tomas.vondra@postgresql.org>
2020-11-06 23:41 pgsql: Properly detoast data in brin_form_tuple Tomas Vondra <tomas.vondra@postgresql.org>
2020-11-06 23:41 pgsql: Properly detoast data in brin_form_tuple Tomas Vondra <tomas.vondra@postgresql.org>
2020-11-06 23:41 pgsql: Properly detoast data in brin_form_tuple Tomas Vondra <tomas.vondra@postgresql.org>
2020-11-06 23:42 pgsql: Properly detoast data in brin_form_tuple Tomas Vondra <tomas.vondra@postgresql.org>

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