Skip to content

Commit a1f0c9b

Browse files
committed
Fix old bug in log_autovacuum_min_duration code: it was relying on being able
to access a Relation entry it had just closed. I happened to be testing with CLOBBER_CACHE_ALWAYS, which made this a guaranteed core dump (at least on machines where sprintf %s isn't forgiving of a NULL pointer). It's probably quite unlikely that it would fail in the field, but a bug is a bug. Fix by moving the relation_close call down past the logging action.
1 parent 9d98486 commit a1f0c9b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/backend/commands/analyze.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.140 2009/08/02 22:14:52 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.141 2009/08/12 18:23:49 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -518,14 +518,6 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt,
518518
/* Done with indexes */
519519
vac_close_indexes(nindexes, Irel, NoLock);
520520

521-
/*
522-
* Close source relation now, but keep lock so that no one deletes it
523-
* before we commit. (If someone did, they'd fail to clean up the entries
524-
* we made in pg_statistic. Also, releasing the lock before commit would
525-
* expose us to concurrent-update failures in update_attstats.)
526-
*/
527-
relation_close(onerel, NoLock);
528-
529521
/* Log the action if appropriate */
530522
if (IsAutoVacuumWorkerProcess() && Log_autovacuum_min_duration >= 0)
531523
{
@@ -540,6 +532,14 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt,
540532
pg_rusage_show(&ru0))));
541533
}
542534

535+
/*
536+
* Close source relation now, but keep lock so that no one deletes it
537+
* before we commit. (If someone did, they'd fail to clean up the entries
538+
* we made in pg_statistic. Also, releasing the lock before commit would
539+
* expose us to concurrent-update failures in update_attstats.)
540+
*/
541+
relation_close(onerel, NoLock);
542+
543543
/*
544544
* Reset my PGPROC flag. Note: we need this here, and not in vacuum_rel,
545545
* because the vacuum flag is cleared by the end-of-xact code.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy