So while looking at this, it suddenly occurred to me that probing with SnapshotDirty isn't that safe for regular (non-TOAST) Oid assignment either. SnapshotDirty will consider a row dead the instant the deleting transaction has committed, but it may remain visible to other transactions for awhile after that --- and now that we use MVCC for catalog scans, that applies to them too. Hence, the existing logic is capable of creating objects with transiently-conflicting OIDs. I don't think this could create a conflict that's visible outside our own transaction, since anyone who can see our commit would also see the commit of the deleting transaction. But there's definitely a hazard inside the transaction that creates a new object.
I propose therefore that the right fix does not require an API change for GetNewOidWithIndex: we can just make it use SnapshotAny all the time. regards, tom lane