pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix misapplication of pgstat_count_truncate to wrong relation. 5+ messages / 1 participants [nested] [flat]
* pgsql: Fix misapplication of pgstat_count_truncate to wrong relation. @ 2018-12-07 17:12 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2018-12-07 17:12 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix misapplication of pgstat_count_truncate to wrong relation. The stanza of ExecuteTruncate[Guts] that truncates a target table's toast relation re-used the loop local variable "rel" to reference the toast rel. This was safe enough when written, but commit d42358efb added code below that that supposed "rel" still pointed to the parent table. Therefore, the stats counter update was applied to the wrong relcache entry (the toast rel not the user rel); and if we were unlucky and that relcache entry had been flushed during reindex_relation, very bad things could ensue. (I'm surprised that CLOBBER_CACHE_ALWAYS testing hasn't found this. I'm even more surprised that the problem wasn't detected during the development of d42358efb; it must not have been tested in any case with a toast table, as the incorrect stats counts are very obvious.) To fix, replace use of "rel" in that code branch with a more local variable. Adjust test cases added by d42358efb so that some of them use tables with toast tables. Per bug #15540 from Pan Bian. Back-patch to 9.5 where d42358efb came in. Discussion: https://postgr.es/m/15540-01078812338195c0@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/5deadfef282761aeb27b18706dcff295e9430c39 Modified Files -------------- src/backend/commands/tablecmds.c | 15 +++++++++------ src/test/regress/expected/stats.out | 4 ++-- src/test/regress/sql/stats.sql | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix misapplication of pgstat_count_truncate to wrong relation. @ 2018-12-07 17:12 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2018-12-07 17:12 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix misapplication of pgstat_count_truncate to wrong relation. The stanza of ExecuteTruncate[Guts] that truncates a target table's toast relation re-used the loop local variable "rel" to reference the toast rel. This was safe enough when written, but commit d42358efb added code below that that supposed "rel" still pointed to the parent table. Therefore, the stats counter update was applied to the wrong relcache entry (the toast rel not the user rel); and if we were unlucky and that relcache entry had been flushed during reindex_relation, very bad things could ensue. (I'm surprised that CLOBBER_CACHE_ALWAYS testing hasn't found this. I'm even more surprised that the problem wasn't detected during the development of d42358efb; it must not have been tested in any case with a toast table, as the incorrect stats counts are very obvious.) To fix, replace use of "rel" in that code branch with a more local variable. Adjust test cases added by d42358efb so that some of them use tables with toast tables. Per bug #15540 from Pan Bian. Back-patch to 9.5 where d42358efb came in. Discussion: https://postgr.es/m/15540-01078812338195c0@postgresql.org Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/078303f79b513ef8f50fdf2a95181c61519e4559 Modified Files -------------- src/backend/commands/tablecmds.c | 15 +++++++++------ src/test/regress/expected/stats.out | 4 ++-- src/test/regress/sql/stats.sql | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix misapplication of pgstat_count_truncate to wrong relation. @ 2018-12-07 17:12 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2018-12-07 17:12 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix misapplication of pgstat_count_truncate to wrong relation. The stanza of ExecuteTruncate[Guts] that truncates a target table's toast relation re-used the loop local variable "rel" to reference the toast rel. This was safe enough when written, but commit d42358efb added code below that that supposed "rel" still pointed to the parent table. Therefore, the stats counter update was applied to the wrong relcache entry (the toast rel not the user rel); and if we were unlucky and that relcache entry had been flushed during reindex_relation, very bad things could ensue. (I'm surprised that CLOBBER_CACHE_ALWAYS testing hasn't found this. I'm even more surprised that the problem wasn't detected during the development of d42358efb; it must not have been tested in any case with a toast table, as the incorrect stats counts are very obvious.) To fix, replace use of "rel" in that code branch with a more local variable. Adjust test cases added by d42358efb so that some of them use tables with toast tables. Per bug #15540 from Pan Bian. Back-patch to 9.5 where d42358efb came in. Discussion: https://postgr.es/m/15540-01078812338195c0@postgresql.org Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/54f24ab76dedb69c03fe4b271c7f53a351637df3 Modified Files -------------- src/backend/commands/tablecmds.c | 15 +++++++++------ src/test/regress/expected/stats.out | 4 ++-- src/test/regress/sql/stats.sql | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix misapplication of pgstat_count_truncate to wrong relation. @ 2018-12-07 17:12 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2018-12-07 17:12 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix misapplication of pgstat_count_truncate to wrong relation. The stanza of ExecuteTruncate[Guts] that truncates a target table's toast relation re-used the loop local variable "rel" to reference the toast rel. This was safe enough when written, but commit d42358efb added code below that that supposed "rel" still pointed to the parent table. Therefore, the stats counter update was applied to the wrong relcache entry (the toast rel not the user rel); and if we were unlucky and that relcache entry had been flushed during reindex_relation, very bad things could ensue. (I'm surprised that CLOBBER_CACHE_ALWAYS testing hasn't found this. I'm even more surprised that the problem wasn't detected during the development of d42358efb; it must not have been tested in any case with a toast table, as the incorrect stats counts are very obvious.) To fix, replace use of "rel" in that code branch with a more local variable. Adjust test cases added by d42358efb so that some of them use tables with toast tables. Per bug #15540 from Pan Bian. Back-patch to 9.5 where d42358efb came in. Discussion: https://postgr.es/m/15540-01078812338195c0@postgresql.org Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/4d5cfb91156d1cc8ede245b8b363468efedf1975 Modified Files -------------- src/backend/commands/tablecmds.c | 15 +++++++++------ src/test/regress/expected/stats.out | 4 ++-- src/test/regress/sql/stats.sql | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix misapplication of pgstat_count_truncate to wrong relation. @ 2018-12-07 17:12 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2018-12-07 17:12 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix misapplication of pgstat_count_truncate to wrong relation. The stanza of ExecuteTruncate[Guts] that truncates a target table's toast relation re-used the loop local variable "rel" to reference the toast rel. This was safe enough when written, but commit d42358efb added code below that that supposed "rel" still pointed to the parent table. Therefore, the stats counter update was applied to the wrong relcache entry (the toast rel not the user rel); and if we were unlucky and that relcache entry had been flushed during reindex_relation, very bad things could ensue. (I'm surprised that CLOBBER_CACHE_ALWAYS testing hasn't found this. I'm even more surprised that the problem wasn't detected during the development of d42358efb; it must not have been tested in any case with a toast table, as the incorrect stats counts are very obvious.) To fix, replace use of "rel" in that code branch with a more local variable. Adjust test cases added by d42358efb so that some of them use tables with toast tables. Per bug #15540 from Pan Bian. Back-patch to 9.5 where d42358efb came in. Discussion: https://postgr.es/m/15540-01078812338195c0@postgresql.org Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/aedd3d4dbd6ecf73a4045e302b68cc498d0e6b58 Modified Files -------------- src/backend/commands/tablecmds.c | 15 +++++++++------ src/test/regress/expected/stats.out | 4 ++-- src/test/regress/sql/stats.sql | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2018-12-07 17:12 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2018-12-07 17:12 pgsql: Fix misapplication of pgstat_count_truncate to wrong relation. Tom Lane <tgl@sss.pgh.pa.us> 2018-12-07 17:12 pgsql: Fix misapplication of pgstat_count_truncate to wrong relation. Tom Lane <tgl@sss.pgh.pa.us> 2018-12-07 17:12 pgsql: Fix misapplication of pgstat_count_truncate to wrong relation. Tom Lane <tgl@sss.pgh.pa.us> 2018-12-07 17:12 pgsql: Fix misapplication of pgstat_count_truncate to wrong relation. Tom Lane <tgl@sss.pgh.pa.us> 2018-12-07 17:12 pgsql: Fix misapplication of pgstat_count_truncate to wrong relation. Tom Lane <tgl@sss.pgh.pa.us>
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