@@ -2511,13 +2511,24 @@ DetermineSafeOldestOffset(MultiXactId oldestMXact)
25112511return ;
25122512
25132513/*
2514- *We determine thesafe upper bound for offsets of new xacts by reading
2515- * the offsetof theoldest multixact, and going back one segment. This
2516- *way, the sequence of multixact member segments will always have a
2517- *one-segment hole at a minimum .We start spewing warnings a few
2518- *complete segments before that .
2514+ *Determine theoffset of the oldest multixact. Normally, we can read
2515+ * the offsetfrom the multixact itself, but there's an important special
2516+ *case: if there are no multixacts in existence at all, oldestMXact
2517+ *obviously can't point to one .It will instead point to the multixact
2518+ *ID that will be assigned the next time one is needed .
25192519 */
2520- oldestOffset = find_multixact_start (oldestMXact );
2520+ LWLockAcquire (MultiXactGenLock ,LW_SHARED );
2521+ if (MultiXactState -> nextMXact == oldestMXact )
2522+ {
2523+ oldestOffset = MultiXactState -> nextOffset ;
2524+ LWLockRelease (MultiXactGenLock );
2525+ }
2526+ else
2527+ {
2528+ LWLockRelease (MultiXactGenLock );
2529+ oldestOffset = find_multixact_start (oldestMXact );
2530+ }
2531+
25212532/* move back to start of the corresponding segment */
25222533oldestOffset -= oldestOffset %
25232534(MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT );