aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2015-06-19 11:28:30 -0400
committerRobert Haas <rhaas@postgresql.org>2015-06-19 11:28:30 -0400
commited16f73c574660aa0902caa1c0adeba07f8c70a5 (patch)
tree3ebcb63f3cccf45c711414dda3de69dc8457a2b2 /src
parent86e4751786bb0dcb29528ef49b067d0e393e4934 (diff)
downloadpostgresql-ed16f73c574660aa0902caa1c0adeba07f8c70a5.tar.gz
postgresql-ed16f73c574660aa0902caa1c0adeba07f8c70a5.zip
Fix corner case in autovacuum-forcing logic for multixact wraparound.
Since find_multixact_start() relies on SimpleLruDoesPhysicalPageExist(), and that function looks only at the on-disk state, it's possible for it to fail to find a page that exists in the in-memory SLRU that has not been written yet. If that happens, SetOffsetVacuumLimit() will erroneously decide to force emergency autovacuuming immediately. We should probably fix find_multixact_start() to consider the data cached in memory as well as on the on-disk state, but that's no excuse for SetOffsetVacuumLimit() to be stupid about the case where it can no longer read the value after having previously succeeded in doing so. Report by Andres Freund.
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/transam/multixact.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 516a89fa2ec..4daa5ae9b02 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -2662,6 +2662,18 @@ SetOffsetVacuumLimit(bool finish_setup)
}
/*
+ * If we failed to get the oldest offset this time, but we have a value
+ * from a previous pass through this function, assess the need for
+ * autovacuum based on that old value rather than automatically forcing
+ * it.
+ */
+ if (prevOldestOffsetKnown && !oldestOffsetKnown)
+ {
+ oldestOffset = prevOldestOffset;
+ oldestOffsetKnown = true;
+ }
+
+ /*
* Do we need an emergency autovacuum? If we're not sure, assume yes.
*/
return !oldestOffsetKnown ||