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-20 05:54:18
Message-ID: CA+hUKGKX5+t1qX_vXyKM_T-_-GHE+nc116uMKDCZy4E3FTxF8A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Apr 18, 2020 at 9:27 PM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
> On Sat, Apr 18, 2020 at 11:47 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> > I think I found another bug in MaintainOldSnapshotTimeMapping(): if
> > you make time jump by more than old_snapshot_threshold in one go, then
> > the map gets cleared and then no early pruning or snapshot-too-old
> > errors happen. That's why in 002_too_old.pl it currently advances
> > time by 10 minutes twice, instead of 20 minutes once. To be
> > continued.
>
> IMHO that doesn't seems to be a problem. Because even if we jump more
> than old_snapshot_threshold in one go we don't clean complete map
> right. The latest snapshot timestamp will become the headtimestamp.
> So in TransactionIdLimitedForOldSnapshots if (current_ts -
> old_snapshot_threshold) is still >= head_timestap then we can still do
> early pruning.

Right, thanks. I got confused about that, and misdiagnosed something
I was seeing.

Here's a new version:

0004: Instead of writing a new kind of TAP test to demonstrate
snapshot-too-old errors, I adjusted the existing isolation tests to
use the same absolute time control technique. Previously I had
invented a way to do isolation tester-like stuff in TAP tests, which
might be interesting but strange new perl is not necessary for this.

0005: Truncates the time map when the CLOG is truncated. Its test is
now under src/test/module/snapshot_too_old/t/001_truncate.sql.

These apply on top of Robert's patches, but the only dependency is on
his patch 0001 "Expose oldSnapshotControl.", because now I have stuff
in src/test/module/snapshot_too_old/test_sto.c that wants to mess with
that object too.

Is this an improvement? I realise that there is still nothing to
actually verify that early pruning has actually happened. I haven't
thought of a good way to do that yet (stats, page inspection, ...).

Attachment Content-Type Size
v3-0004-Rewrite-the-snapshot_too_old-tests-with-absolute-.patch text/x-patch 24.5 KB
v3-0005-Truncate-snapshot-too-old-time-map-when-CLOG-is-t.patch text/x-patch 8.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-04-20 06:00:09 Re: where should I stick that backup?
Previous Message Masahiko Sawada 2020-04-20 05:35:23 Re: Race condition in SyncRepGetSyncStandbysPriority