Re: pg_amcheck contrib application - Mailing list pgsql-hackers
From | Mark Dilger |
---|---|
Subject | Re: pg_amcheck contrib application |
Date | |
Msg-id | 5F68992D-B92B-4715-B0FA-2E1651EF147A@enterprisedb.com Whole thread Raw |
In response to | Re: pg_amcheck contrib application (Robert Haas <robertmhaas@gmail.com>) |
Responses |
Re: pg_amcheck contrib application
Re: pg_amcheck contrib application |
List | pgsql-hackers |
> On Mar 31, 2021, at 10:11 AM, Robert Haas <robertmhaas@gmail.com> wrote: > > On Wed, Mar 31, 2021 at 12:34 AM Mark Dilger > <mark.dilger@enterprisedb.com> wrote: >> I'm not looking at the old VACUUM FULL code, but my assumption is that if the xvac code were resurrected, then when atuple is moved off by a VACUUM FULL, the old tuple and associated toast cannot be pruned until concurrent transactions end. So, if amcheck is running more-or-less concurrently with the VACUUM FULL and has a snapshot xmin no newer than the xidof the VACUUM FULL's xid, it can check the toast associated with the moved off tuple after the VACUUM FULL commits. Ifinstead the VACUUM FULL xid was older than amcheck's xmin, then the toast is in danger of being vacuumed away. So thelogic in verify_heapam would need to change to think about this distinction. We don't have to concern ourselves aboutthat, because VACUUM FULL cannot be running, and so the xid for it must be older than our xmin, and hence the toastis unconditionally not safe to check. >> >> I'm changing the comments back to how you had them, but I'd like to know why my reasoning is wrong. > > Let's start by figuring out *whether* your reasoning is wrong. My > assumption was that old-style VACUUM FULL would move tuples without > retoasting. That is, if we decided to move a tuple from page 2 of the > main table to page 1, we would just write the tuple into page 1, > marking it moved-in, and on page 2 we would mark it moved-off. And > that we would not examine or follow any TOAST pointers at all, so > whatever TOAST entries existed would be shared between the two tuples. > One tuple or the other would eventually die, depending on whether xvac > went on to commit or abort, but either way the TOAST doesn't need > updating because there's always exactly 1 remaining tuple using > pointers to those TOAST values. > > Your assumption seems to be the opposite, that the TOASTed values > would be retoasted as part of VF. If that is true, then your idea is > right. > > Do you agree with this analysis? If so, we can check the code and find > out which way it actually worked. Actually, that makes a lot of sense without even looking at the old code. I was implicitly assuming that the toast tablewas undergoing a VF also, and that the toast pointers in the main table tuples would be updated to point to the newlocation, so we'd be unable to follow the pointers to the old location without danger of the old location entries beingvacuumed away. But if the main table tuples get moved while keeping their toast pointers unaltered, then you don'thave to worry about that, although you do have to worry that a VF of the main table doesn't help so much with toasttable bloat. We're only discussing this in order to craft the right comment for a bit of code with respect to a hypothetical situationin which VF gets resurrected, so I'm not sure this should be top priority, but I'm curious enough now to go readthe old code.... — Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
pgsql-hackers by date: