@@ -2492,13 +2492,24 @@ DetermineSafeOldestOffset(MultiXactId oldestMXact)
24922492return ;
24932493
24942494/*
2495- *We determine thesafe upper bound for offsets of new xacts by reading
2496- * the offsetof theoldest multixact, and going back one segment. This
2497- *way, the sequence of multixact member segments will always have a
2498- *one-segment hole at a minimum .We start spewing warnings a few
2499- *complete segments before that .
2495+ *Determine theoffset of the oldest multixact. Normally, we can read
2496+ * the offsetfrom the multixact itself, but there's an important special
2497+ *case: if there are no multixacts in existence at all, oldestMXact
2498+ *obviously can't point to one .It will instead point to the multixact
2499+ *ID that will be assigned the next time one is needed .
25002500 */
2501- oldestOffset = find_multixact_start (oldestMXact );
2501+ LWLockAcquire (MultiXactGenLock ,LW_SHARED );
2502+ if (MultiXactState -> nextMXact == oldestMXact )
2503+ {
2504+ oldestOffset = MultiXactState -> nextOffset ;
2505+ LWLockRelease (MultiXactGenLock );
2506+ }
2507+ else
2508+ {
2509+ LWLockRelease (MultiXactGenLock );
2510+ oldestOffset = find_multixact_start (oldestMXact );
2511+ }
2512+
25022513/* move back to start of the corresponding segment */
25032514oldestOffset -= oldestOffset %
25042515(MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT );