> On Mar 15, 2021, at 11:57 AM, Tom Lane <t...@sss.pgh.pa.us> wrote:
> 
> Do we have a strong enough lock on
> the table under examination to be sure that autovacuum couldn't remove
> a dead toast entry before we reach it?

The main table and the toast table are only locked with AccessShareLock.  Each 
page in the main table is locked with BUFFER_LOCK_SHARE.  Toast is not checked 
unless the tuple passes visibility checks verifying the tuple is not dead.

>  But this would only be an
> issue if we are trying to check validity of toasted fields within
> known-dead tuples, which I would argue we shouldn't, since lock or
> no lock there's no guarantee the toast entry is still there.

It does not intentionally check toasted fields within dead tuples.  If that is 
happening, it's a bug, possibly in the visibility function.  But I'm not seeing 
a specific reason to assume that is the issue.  If we still see the complaint 
on tern or hornet after committing the patch to turn off autovacuum, we will be 
able to rule out the theory that the toast was removed by autovacuum.

—
Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company





Reply via email to