Re: Fix missing EvalPlanQual recheck for TID scans

From: "Sophie Alpert" <pg(at)sophiebits(dot)com>
To: "Chao Li" <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: "David Rowley" <dgrowleyml(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Fix missing EvalPlanQual recheck for TID scans
Date: 2025-09-14 03:02:00
Message-ID: c536bcf7-8cee-4fc1-8ed8-69408da88f7d@app.fastmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Sep 13, 2025 at 3:12 PM, Sophie Alpert <pg(at)sophiebits(dot)com> wrote:
> And indeed, like I mentioned in my previous message, my isolation test
> `permutation tid1 tidsucceed2 c1 c2 read` from eval-plan-qual.spec in
> my patch will fail if Recheck were to return false in this case. Though
> somewhat contrived, you can imagine this happening with multiple
> sessions driven by the same application:

Another case where returning FALSE does not give the correct behavior is when two relations are involved, only one of which is modified:

S1: BEGIN;
S2: BEGIN;
S1: UPDATE accounts SET balance = balance + 100 WHERE ctid = '(0,1)' RETURNING accountid, balance;
S2: SELECT * FROM accounts JOIN accounts_ext USING (accountid) WHERE accounts_ext.ctid = '(0,1)' FOR UPDATE OF accounts;
S1: COMMIT;
S2: COMMIT;

In my patch the S2 query correctly returns one row, whereas with your proposed change it incorrectly returns none.

accountid|balance|balance2|balance|other|newcol|newcol2
---------+-------+--------+-------+-----+------+-------
checking | 700| 1400| 600|other| 42|

Sophie

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2025-09-14 03:23:55 Re: meson's in-tree libpq header search order vs -Dextra_include_dirs
Previous Message Peter Geoghegan 2025-09-14 01:03:06 Re: Adding skip scan (including MDAM style range skip scan) to nbtree