1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-18 17:41:14 +03:00

Fix DetermineSafeOldestOffset for the case where there are no mxacts.

Commit b69bf30b9bfacafc733a9ba77c9587cf54d06c0c failed to take into
account the possibility that there might be no multixacts in existence
at all.

Report by Thomas Munro; patch by me.
This commit is contained in:
Robert Haas 2015-05-10 21:34:26 -04:00
parent 3de791ee76
commit 24aa77ec95

View File

@ -2511,13 +2511,24 @@ DetermineSafeOldestOffset(MultiXactId oldestMXact)
return; return;
/* /*
* We determine the safe upper bound for offsets of new xacts by reading * Determine the offset of the oldest multixact. Normally, we can read
* the offset of the oldest multixact, and going back one segment. This * the offset from the multixact itself, but there's an important special
* way, the sequence of multixact member segments will always have a * case: if there are no multixacts in existence at all, oldestMXact
* one-segment hole at a minimum. We start spewing warnings a few * obviously can't point to one. It will instead point to the multixact
* complete segments before that. * ID that will be assigned the next time one is needed.
*/ */
LWLockAcquire(MultiXactGenLock, LW_SHARED);
if (MultiXactState->nextMXact == oldestMXact)
{
oldestOffset = MultiXactState->nextOffset;
LWLockRelease(MultiXactGenLock);
}
else
{
LWLockRelease(MultiXactGenLock);
oldestOffset = find_multixact_start(oldestMXact); oldestOffset = find_multixact_start(oldestMXact);
}
/* move back to start of the corresponding segment */ /* move back to start of the corresponding segment */
oldestOffset -= oldestOffset % oldestOffset -= oldestOffset %
(MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT); (MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT);