Re: Wrong usage of RelationNeedsWAL

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: noah(at)leadboat(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org, andres(at)anarazel(dot)de
Subject: Re: Wrong usage of RelationNeedsWAL
Date: 2021-01-20 15:28:44
Message-ID: 20210121.002844.690876870629206205.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Wed, 20 Jan 2021 17:34:44 +0900 (JST), Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> wrote in
> Anyway, it seems actually dangerous that cause pruning on wal-skipped
> relation.
>
> > with your patch versions. Could you try implementing both test procedures in
> > src/test/modules/snapshot_too_old? There's no need to make the test use
> > wal_level=minimal explicitly; it's sufficient to catch these bugs when
> > wal_level=minimal is in the TEMP_CONFIG file.
>
> In the attached, TestForOldSnapshot() considers XLogIsNeeded(),
> instead of moving the condition on LSN to TestForOldSnapshot_impl for
> performance.
>
> I'll add the test part in the next version.

This is it.

However, with the previous patch, two existing tests sto_using_cursor
and sto_using_select behaves differently from the master. That change
is coming from the omission of actual LSN check in TestForOldSnapshot
while wal_level=minimal. So we have no choice other than actually
updating page LSN.

In the scenario under discussion there are two places we need to do
that. one is heap_page_prune, and the other is RelationCopyStorge. As
a PoC, I used gistXLogAssignLSN() as is for thie purpose. See the
attached third file.

If it is the right direction, I will move XLOG_GIST_ASSIGN_LSN to
XLOG_ASSIGN_LSN and move gistXLogAssignLSN() to XLogAdvanceLSN() or
XLogNop() or such.

With the third patch, the test succedds both wal_level = replica and
minimal.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
v5-0001-Test-for-snapshot-too-old-and-wal_level-minimal.patch text/x-patch 4.9 KB
v5-0002-Do-not-use-RelationNeedsWAL-to-identify-relation-.patch text/x-patch 4.0 KB
v5-0003-Poc-Keep-page-LSN-updated-while-WAL-skipping.patch text/x-patch 4.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2021-01-20 15:43:22 Re: pg_stat_statements oddity with track = all
Previous Message Dian M Fay 2021-01-20 14:58:43 Re: [HACKERS] [PATCH] Generic type subscripting