pgstat: fix small bug in pgstat_drop_relation().
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.
This commit is contained in:
parent
81ae9e6588
commit
5e07d3d6bd
@ -180,18 +180,21 @@ void
|
|||||||
pgstat_drop_relation(Relation rel)
|
pgstat_drop_relation(Relation rel)
|
||||||
{
|
{
|
||||||
int nest_level = GetCurrentTransactionNestLevel();
|
int nest_level = GetCurrentTransactionNestLevel();
|
||||||
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
|
PgStat_TableStatus *pgstat_info;
|
||||||
|
|
||||||
pgstat_drop_transactional(PGSTAT_KIND_RELATION,
|
pgstat_drop_transactional(PGSTAT_KIND_RELATION,
|
||||||
rel->rd_rel->relisshared ? InvalidOid : MyDatabaseId,
|
rel->rd_rel->relisshared ? InvalidOid : MyDatabaseId,
|
||||||
RelationGetRelid(rel));
|
RelationGetRelid(rel));
|
||||||
|
|
||||||
|
if (!pgstat_should_count_relation(rel))
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Transactionally set counters to 0. That ensures that accesses to
|
* Transactionally set counters to 0. That ensures that accesses to
|
||||||
* pg_stat_xact_all_tables inside the transaction show 0.
|
* pg_stat_xact_all_tables inside the transaction show 0.
|
||||||
*/
|
*/
|
||||||
if (pgstat_info &&
|
pgstat_info = rel->pgstat_info;
|
||||||
pgstat_info->trans != NULL &&
|
if (pgstat_info->trans &&
|
||||||
pgstat_info->trans->nest_level == nest_level)
|
pgstat_info->trans->nest_level == nest_level)
|
||||||
{
|
{
|
||||||
save_truncdrop_counters(pgstat_info->trans, true);
|
save_truncdrop_counters(pgstat_info->trans, true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user