diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index cb12fc3..cb4a0cd 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -2945,29 +2945,6 @@ SlruScanDirCbRemoveMembers(SlruCtl ctl, char *filename, int segpage, return false; /* keep going */ } -typedef struct mxtruncinfo -{ - int earliestExistingPage; -} mxtruncinfo; - -/* - * SlruScanDirectory callback - * This callback determines the earliest existing page number. - */ -static bool -SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data) -{ - mxtruncinfo *trunc = (mxtruncinfo *) data; - - if (trunc->earliestExistingPage == -1 || - ctl->PagePrecedes(segpage, trunc->earliestExistingPage)) - { - trunc->earliestExistingPage = segpage; - } - - return false; /* keep going */ -} - /* * Remove all MultiXactOffset and MultiXactMember segments before the oldest * ones still of interest. @@ -2986,8 +2963,6 @@ TruncateMultiXact(void) MultiXactOffset oldestOffset; MultiXactId nextMXact; MultiXactOffset nextOffset; - mxtruncinfo trunc; - MultiXactId earliest; MembersLiveRange range; Assert(AmCheckpointerProcess() || AmStartupProcess() || @@ -3001,49 +2976,20 @@ TruncateMultiXact(void) Assert(MultiXactIdIsValid(oldestMXact)); /* - * Note we can't just plow ahead with the truncation; it's possible that - * there are no segments to truncate, which is a problem because we are - * going to attempt to read the offsets page to determine where to - * truncate the members SLRU. So we first scan the directory to determine - * the earliest offsets page number that we can read without error. - */ - trunc.earliestExistingPage = -1; - SlruScanDirectory(MultiXactOffsetCtl, SlruScanDirCbFindEarliest, &trunc); - earliest = trunc.earliestExistingPage * MULTIXACT_OFFSETS_PER_PAGE; - if (earliest < FirstMultiXactId) - earliest = FirstMultiXactId; - - /* - * If there's nothing to remove, we can bail out early. - * - * Due to bugs in early releases of PostgreSQL 9.3.X and 9.4.X, - * oldestMXact might point to a multixact that does not exist. - * Autovacuum will eventually advance it to a value that does exist, - * and we want to set a proper offsetStopLimit when that happens, - * so call DetermineSafeOldestOffset here even if we're not actually - * truncating. - */ - if (MultiXactIdPrecedes(oldestMXact, earliest)) - { - DetermineSafeOldestOffset(oldestMXact); - return; - } - - /* * First, compute the safe truncation point for MultiXactMember. This is * the starting offset of the oldest multixact. * - * Hopefully, find_multixact_start will always work here, because we've - * already checked that it doesn't precede the earliest MultiXact on - * disk. But if it fails, don't truncate anything, and log a message. + * Due to bugs in early releases of PostgreSQL 9.3.X and 9.4.X, + * oldestMXact might point to a multixact that does not exist. Call + * DetermineSafeOldestOffset() to emit the message about disabled member + * wraparound protection. Autovacuum will eventually advance oldestMXact + * to a value that does exist. */ if (oldestMXact == nextMXact) oldestOffset = nextOffset; /* there are NO MultiXacts */ else if (!find_multixact_start(oldestMXact, &oldestOffset)) { - ereport(LOG, - (errmsg("oldest MultiXact %u not found, earliest MultiXact %u, skipping truncation", - oldestMXact, earliest))); + DetermineSafeOldestOffset(oldestMXact); return; }