Re: fixing old_snapshot_threshold's time->xid mapping

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Kevin Grittner <kgrittn(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: fixing old_snapshot_threshold's time->xid mapping
Date: 2020-04-21 02:05:18
Message-ID: CA+hUKGLSB7JqRdjBLs-G33sWuJR-XgU5pQ=KALdy9p_ZuqcAWg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Apr 20, 2020 at 8:02 PM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
> On Mon, Apr 20, 2020 at 12:29 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> > I mean I want to verify that VACUUM or heap prune actually removed a
> > tuple that was visible to an old snapshot. An idea I just had: maybe
> > sto_using_select.spec should check the visibility map (somehow). For
> > example, the sto_using_select.spec (the version in the patch I just
> > posted) just checks that after time 00:11, the old snapshot gets a
> > snapshot-too-old error. Perhaps we could add a VACUUM before that,
> > and then check that the page has become all visible, meaning that the
> > dead tuple our snapshot could see has now been removed.
>
> Okay, got your point. Can we try to implement some test functions
> that can just call visibilitymap_get_status function internally? I
> agree that we will have to pass the correct block number but that we
> can find using TID. Or for testing, we can create a very small
> relation that just has 1 block?

I think it's enough to check SELECT EVERY(all_visible) FROM
pg_visibility_map('sto1'::regclass). I realised that
src/test/module/snapshot_too_old is allowed to install
contrib/pg_visibility with EXTRA_INSTALL, so here's a new version to
try that idea. It extends sto_using_select.spec to VACUUM and check
the vis map at key times. That allows us to check that early pruning
really happens once the snapshot becomes too old. There are other
ways you could check that but this seems quite "light touch" compared
to something based on page inspection.

I also changed src/test/module/snapshot_too_old/t/001_truncate.pl back
to using Robert's contrib/old_snapshot extension to know the size of
the time/xid map, allowing an introspection function to be dropped
from test_sto.c.

As before, these two apply on top of Robert's patches (or at least his
0001 and 0002).

Attachment Content-Type Size
v4-0004-Rewrite-the-snapshot_too_old-tests.patch text/x-patch 28.3 KB
v4-0005-Truncate-snapshot-too-old-time-map-when-CLOG-is-t.patch text/x-patch 7.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2020-04-21 02:15:01 Re: [BUG] non archived WAL removed during production crash recovery
Previous Message Michael Paquier 2020-04-21 01:59:28 Re: Remove non-fast promotion Re: Should we remove a fallback promotion? take 2