On Wed, Apr 11, 2018 at 8:20 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Pavan Deolasee <pavan.deolasee@gmail.com> writes: > Or may be we simply err on the side of caution and scan the toast table > with SnapshotAny while looking for a duplicate? That might prevent us from > reusing an OID for a known-dead tuple, but should save us a second index > scan and still work.
+1. We really don't want to expend two indexscans on this.
Ok. I propose attached patches, more polished this time. I also changed toastrel_valueid_exists() to use SnapshotAny, but I don't have any proofs to claim that's a needed change. But it seems harmless and given the number of toast related, hard to chase bugs we have seen over the years, may it's worth making it full proof too.