Re: BUG: Postgres 14 + vacuum_defer_cleanup_age + FOR UPDATE + UPDATE
Matthias van de Meent <boekewurm+postgres@gmail.com>
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Michail Nikolaev <michail.nikolaev@gmail.com>,
Thomas Munro <thomas.munro@gmail.com>, Peter Geoghegan <pg@bowt.ie>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Robert Haas <robertmhaas@gmail.com>,
Mark Dilger <mark.dilger@enterprisedb.com>
Date: 2023-02-01T00:23:09Z
Lists: pgsql-hackers
On Tue, 31 Jan 2023 at 23:48, Andres Freund <andres@anarazel.de> wrote: > > Hi, > > On 2023-01-31 15:05:17 +0100, Matthias van de Meent wrote: > > If TransactionIdRetreatSafely will be exposed outside procarray.c, > > then I think the xid pointer should be replaced with normal > > arguments/returns; both for parity with TransactionIdRetreatedBy > > That's why I named one version *Retreat the other Retreated :) That part I noticed too :) I don't mind either way, I was just concerned with exposing the function as a prototype, not as an inline static. > I think it'll make the code easier to read in the other places too, the > variable names / function names in this space are uncomfortably long to > fit into 78chars..., particularly when there's two references to the > same variable in the same line. I guess that's true, and once inlined there should indeed be no extra runtime overhead. > 78 chars Didn't we use 80 columns/chars? How did you get to 78? Not that I can't think of any ways, but none of them stand out to me as obviously correct. > > and to remove this memory store dependency in this hot code path. > > I doubt that matters much here and the places it's going to be used > in. I thought that this was executed while still in ProcArrayLock, but instead we've released that lock already by the time we're trying to adjust the horizons, so the 'hot code path' concern is mostly relieved. > And presumably the compiler will inline it anyway. I'd probably make > it a static inline in the header too. Yes, my concern was based on an extern prototype with private implementation, as that does prohibit inlining and thus would have a requirement to push the data to memory (probably only L1, but still memory). > What's making me hesitate about exposing it is that it's quite easy to > get things wrong by using a wrong fxid or such. I'm less concerned about that when the function is well-documented. > > > + /* > > > + * FIXME, doubtful this is the best fix. > > > + * > > > + * Can't represent the 32bit xid as a 64bit xid, as it's before fxid > > > + * 0. Represent it as an xid from the future instead. > > > + */ > > > + if (epoch == 0) > > > + return FullTransactionIdFromEpochAndXid(0, xid); > > > > Shouldn't this be an error condition instead, as this XID should not > > be able to appear? > > If you mean error in the sense of ERROR, no, I don't think so. That code > tries hard to be able to check many tuples in a row. And if we were to > error out here, we'd not able to do that. We should still report those > tuples as corrupt, fwiw. > > The reason this path is hit is that a test intentionally corrupts some > xids. So the path is reachable and we need to cope somehow. I see. Kind regards, Matthias van de Meent
Commits
-
Fix incorrect TAP test ordering
- 92155e15d3cf 16.0 landed
-
pg_amcheck: Minor test speedups
- a4f23f9b3cdd 16.0 landed
-
amcheck: Fix FullTransactionIdFromXidAndCtx() for xids before epoch 0
- b3a83055c235 14.8 landed
- e8a9750d03d7 15.3 landed
- 4f5d461e048b 16.0 landed
-
amcheck: Fix ordering bug in update_cached_xid_range()
- a42f515d6b45 14.8 landed
- 6d9588108a56 15.3 landed
- 16327240da29 16.0 landed
-
Fix corruption due to vacuum_defer_cleanup_age underflowing 64bit xids
- be504a3e974d 16.0 landed
- 3c92f7e9d851 12.15 landed
- e6d77f22c7a8 13.11 landed
- 324281fd5b1b 14.8 landed
- 391f08fd6804 15.3 landed
-
Add hardening to catch invalid TIDs in indexes.
- e7428a99a13f 15.0 cited
-
Use full 64-bit XID for checking if a deleted GiST page is old enough.
- 6655a7299d83 13.0 cited
-
Avoid early reuse of btree pages, causing incorrect query results.
- d3abbbebe52e 9.2.0 cited