Re: Hot Standby btree delete records and vacuum_defer_cleanup_age

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>

From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: Simon Riggs <simon@2ndQuadrant.com>
Cc: pgsql-hackers@postgresql.org
Date: 2010-12-08T23:39:29Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Reduce spurious Hot Standby conflicts from never-visible records.

On 08.12.2010 16:00, Simon Riggs wrote:
>
> Heikki pointed out to me that the btree delete record processing does
> not respect vacuum_defer_cleanup_age. It should.
>
> Attached patch to implement that.

This doesn't look right to me. btree_xlog_delete_get_latestRemovedXid() 
function calculates the latest XID present on the tuples that we're 
removing b-tree pointers for. btree_xlog_delete_get_latestRemovedXid() 
is used during recovery. vacuum_defer_cleanup_age should take effect in 
the master, not during recovery.

With the patch, btree_xlog_delete_get_latestRemovedXid() returns a value 
that's much smaller than it should. That's just wrong, it means that 
recovery in the standby will incorrectly think that all the removed 
tuples are old and not visible to any running read-only queries anymore, 
and will go ahead and remove the index tuples for them.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com