Re: Amcheck: do rightlink verification with lock coupling

2019-09-12 Thread Alvaro Herrera
On 2019-Sep-12, Andrey Borodin wrote:

> This patch violates one of amcheck design principles: current code
> does not ever take more than one page lock. I do not know: should we
> hold this rule or should we use more deep check?

The check does seem worthwhile to me.

As far as I know, in btree you can lock the right sibling of a page
while keeping lock on the page itself, without risk of deadlock.  So I'm
not sure what's the issue with that.  This is in the README:

  In most cases we release our lock and pin on a page before attempting
  to acquire pin and lock on the page we are moving to.  In a few places
  it is necessary to lock the next page before releasing the current one.
  This is safe when moving right or up, but not when moving left or down
  (else we'd create the possibility of deadlocks).

I suppose Peter was concerned about being able to run amcheck without
causing any trouble at all for concurrent operation; maybe we can retain
that property by making this check optional.

-- 
Álvaro Herrerahttps://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




Amcheck: do rightlink verification with lock coupling

2019-09-12 Thread Andrey Borodin
Hi!

This is a thread to discuss amcheck feature started in other thread[0].

Currently amcheck is scanning every B-tree level. If verification is done with 
ShareLock - amcheck will test that each page leftlink is pointing to page with 
rightlink backwards.
This is important invariant, in our experience it proved to be good at 
detecting various corruptions.
But this invariant can be detected only if both pages are not modified (e.g. 
split concurrently).

PFA patch, that in case of suspicion locks two pages and retests that 
invariant. This allows detection of several corruptions on standby.

This patch violates one of amcheck design principles: current code does not 
ever take more than one page lock. I do not know: should we hold this rule or 
should we use more deep check?

Thanks!

Best regards, Andrey Borodin.

[0] 
https://www.postgresql.org/message-id/flat/da9b33ac-53cb-4643-96d4-7a0bbc037...@yandex-team.ru


v2-0001-In-amcheck-nbtree-do-rightlink-verification-with-loc.patch
Description: Binary data