Skip to content

Commit 357c845

Browse files
Adjust VACUUM's removable cutoff log message.
The age of OldestXmin (a.k.a. "removable cutoff") when VACUUM ends often indicates the approximate number of XIDs consumed while VACUUM ran. However, there is at least one important exception: the cutoff could be held back by a snapshot that was acquired before our VACUUM even began. Successive VACUUM operations may even use exactly the same old cutoff in extreme cases involving long held snapshots. The log messages that described how removable cutoff aged (which were added by commit 872770f) created the impression that we were reporting on how VACUUM's usable cutoff advanced while VACUUM ran, which was misleading in these extreme cases. Fix by using a more general wording. Per gripe from Tom Lane. In passing, relocate related instrumentation code for clarity. Author: Peter Geoghegan <pg@bowt.ie> Discussion: https://postgr.es/m/1643035.1650035653@sss.pgh.pa.us
1 parent 9199853 commit 357c845

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

src/backend/access/heap/vacuumlazy.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -633,30 +633,19 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
633633
TimestampDifferenceExceeds(starttime, endtime,
634634
params->log_min_duration))
635635
{
636-
long secs;
637-
int usecs;
636+
long secs_dur;
637+
int usecs_dur;
638638
WalUsage walusage;
639-
double read_rate,
640-
write_rate;
641639
StringInfoData buf;
642640
char *msgfmt;
643641
int32 diff;
642+
double read_rate = 0,
643+
write_rate = 0;
644644

645-
TimestampDifference(starttime, endtime, &secs, &usecs);
646-
645+
TimestampDifference(starttime, endtime, &secs_dur, &usecs_dur);
647646
memset(&walusage, 0, sizeof(WalUsage));
648647
WalUsageAccumDiff(&walusage, &pgWalUsage, &walusage_start);
649648

650-
read_rate = 0;
651-
write_rate = 0;
652-
if ((secs > 0) || (usecs > 0))
653-
{
654-
read_rate = (double) BLCKSZ * VacuumPageMiss / (1024 * 1024) /
655-
(secs + usecs / 1000000.0);
656-
write_rate = (double) BLCKSZ * VacuumPageDirty / (1024 * 1024) /
657-
(secs + usecs / 1000000.0);
658-
}
659-
660649
initStringInfo(&buf);
661650
if (verbose)
662651
{
@@ -710,20 +699,20 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
710699
vacrel->missed_dead_pages);
711700
diff = (int32) (ReadNextTransactionId() - OldestXmin);
712701
appendStringInfo(&buf,
713-
_("removable cutoff: %u, older by %d xids when operation ended\n"),
702+
_("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
714703
OldestXmin, diff);
715704
if (frozenxid_updated)
716705
{
717706
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
718707
appendStringInfo(&buf,
719-
_("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
708+
_("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
720709
vacrel->NewRelfrozenXid, diff);
721710
}
722711
if (minmulti_updated)
723712
{
724713
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
725714
appendStringInfo(&buf,
726-
_("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
715+
_("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
727716
vacrel->NewRelminMxid, diff);
728717
}
729718
if (orig_rel_pages > 0)
@@ -774,6 +763,13 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
774763
appendStringInfo(&buf, _("I/O timings: read: %.3f ms, write: %.3f ms\n"),
775764
read_ms, write_ms);
776765
}
766+
if (secs_dur > 0 || usecs_dur > 0)
767+
{
768+
read_rate = (double) BLCKSZ * VacuumPageMiss / (1024 * 1024) /
769+
(secs_dur + usecs_dur / 1000000.0);
770+
write_rate = (double) BLCKSZ * VacuumPageDirty / (1024 * 1024) /
771+
(secs_dur + usecs_dur / 1000000.0);
772+
}
777773
appendStringInfo(&buf, _("avg read rate: %.3f MB/s, avg write rate: %.3f MB/s\n"),
778774
read_rate, write_rate);
779775
appendStringInfo(&buf,

0 commit comments

Comments
 (0)