Thread: BUG #13878: Hot Standby Query Conflict documentation leaves out a potential source of conflict errors

The following bug has been logged on the website:

Bug reference:      13878
Logged by:          Wayne Lewis
Email address:      wayne+psql@lewisclan.org
PostgreSQL version: 9.3.9
Operating system:   Ubuntu 14.04
Description:

In 25.5.2 of the documentation the reasons for conflict errors are listed.

The first case is "Access Exclusive" which lists the ways an
AccessExclusiveLock can be taken on master which could conflict with queries
on the standby.

I think it should be noted there that even a lazy vacuum (and specifically
auto vacuum) can take AccessExclusiveLock when truncating free pages from a
relation, and that lock can produce a "User was holding a relation lock for
too long." error on the standby when the standby has long overlapping
queries on that relation.

I didn't realize until researching the source that auto vacuum can take an
AccessExclusiveLock in lazy_truncate_heap() and I suspect most users do not
realize that either.

While documentation to this effect would be very useful, is it possible to
go further and introduce a flag that disables truncation during lazy vacuum
whenever there is  a standby? If there is no consequence to leaving those
pages I think users would prefer to control when an AccessExclusiveLock can
sneak into the WAL.

Thanks!
Wayne