git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 81ae9e6)
pgstat: fix small bug in pgstat_drop_relation().
Thu, 7 Apr 2022 06:35:56 +0000 (23:35 -0700)
Thu, 7 Apr 2022 06:35:56 +0000 (23:35 -0700)
Just after committing 5891c7a8ed8, a test running with debug_discard_caches=1
failed locally...

pgstat_drop_relation() neither checked pgstat_should_count_relation() nor
called pgstat_prep_relation_pending(). With debug_discard_caches=1
rel->pgstat_info wasn't set up, leading pg_stat_get_xact_tuples_inserted()
spuriously still returning > 0 while in the transaction dropping the table.


diff --git a/src/backend/utils/activity/pgstat_relation.c b/src/backend/utils/activity/pgstat_relation.c
index bec190c589753883d96d84cd2591dc02ed85849f..a846d9ffb652b5586d3b784a083ce2d9369b7299 100644 (file)
--- a/src/backend/utils/activity/pgstat_relation.c
+++ b/src/backend/utils/activity/pgstat_relation.c
@@ -180,18 +180,21 @@ void
pgstat_drop_relation(Relation rel)
{
int nest_level = GetCurrentTransactionNestLevel();
- PgStat_TableStatus *pgstat_info = rel->pgstat_info;
+ PgStat_TableStatus *pgstat_info;
pgstat_drop_transactional(PGSTAT_KIND_RELATION,
rel->rd_rel->relisshared ? InvalidOid : MyDatabaseId,
RelationGetRelid(rel));
+ if (!pgstat_should_count_relation(rel))
+ return;
+
/*
* Transactionally set counters to 0. That ensures that accesses to
* pg_stat_xact_all_tables inside the transaction show 0.
*/
- if (pgstat_info &&
- pgstat_info->trans != NULL &&
+ pgstat_info = rel->pgstat_info;
+ if (pgstat_info->trans &&
pgstat_info->trans->nest_level == nest_level)
{
save_truncdrop_counters(pgstat_info->trans, true);
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /