diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-03-08 17:03:43 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-03-08 17:03:43 +0000 |
commit | 8e010acb0d5f12cc49e40ba1f5f92e3692a3932f (patch) | |
tree | b0922c47efe5249a947076d87d812bd1c91d4555 /src | |
parent | 2b1abc8756e973a098943c255c3cbeb2568cfb91 (diff) | |
download | postgresql-8e010acb0d5f12cc49e40ba1f5f92e3692a3932f.tar.gz postgresql-8e010acb0d5f12cc49e40ba1f5f92e3692a3932f.zip |
Fix vac_update_relstats to ensure it always sends a relcache inval message,
even if none of the fields in the pg_class row change. This behavior is
necessary to ensure other backends flush rd_targblock values that might
point to truncated-away pages. We got this right pre-8.2 but it was broken
by overoptimistic change to not write out the pg_class row if unchanged.
Per report from Pavan Deolasee.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/commands/vacuum.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index b15fcc1059f..9fd7a7e6958 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.342 2006/11/05 22:42:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.342.2.1 2007/03/08 17:03:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -715,10 +715,20 @@ vac_update_relstats(Oid relid, BlockNumber num_pages, double num_tuples, } /* - * If anything changed, write out the tuple + * If anything changed, write out the tuple. Even if nothing changed, + * force relcache invalidation so all backends reset their rd_targblock + * --- otherwise it might point to a page we truncated away. */ if (dirty) + { heap_inplace_update(rd, ctup); + /* the above sends a cache inval message */ + } + else + { + /* no need to change tuple, but force relcache inval anyway */ + CacheInvalidateRelcacheByTuple(ctup); + } heap_close(rd, RowExclusiveLock); } |