Re: PANIC: wrong buffer passed to visibilitymap_clear

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>, Peter Geoghegan <pg@bowt.ie>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2021-04-09T23:32:03Z
Lists: pgsql-hackers
On 2021-04-09 16:27:39 -0700, Andres Freund wrote:
> Just looking at the code in heap_update: I'm a bit confused about
> RelationGetBufferForTuple()'s vmbuffer and vmbuffer_other
> arguments. It looks like it's not at all clear which of the two
> arguments will have the vmbuffer for which of the pages?
> 
> 		if (otherBuffer == InvalidBuffer || targetBlock <= otherBlock)
> 			GetVisibilityMapPins(relation, buffer, otherBuffer,
> 								 targetBlock, otherBlock, vmbuffer,
> 								 vmbuffer_other);
> 		else
> 			GetVisibilityMapPins(relation, otherBuffer, buffer,
> 								 otherBlock, targetBlock, vmbuffer_other,
> 								 vmbuffer);

Oh, I missed that the arguments to GetVisibilityMapPins are
appropriately swapped too.

Greetings,

Andres Freund



Commits

  1. Avoid improbable PANIC during heap_update.

  2. Refactor lazy_scan_heap() loop.