Re: suboverflowed subtransactions concurrency performance optimize
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Andres Freund <andres@anarazel.de>
Cc: Amit Kapila <amit.kapila16@gmail.com>, Julien Rouhaud <rjuju123@gmail.com>, Simon Riggs <simon.riggs@enterprisedb.com>, Andrey Borodin <x4mmm@yandex-team.ru>, Pengchengliu <pengchengliu@tju.edu.cn>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2022-05-28T06:21:58Z
Lists: pgsql-hackers
On Fri, May 27, 2022 at 08:55:02AM -0700, Andres Freund wrote: > On 2022-05-27 15:44:39 +0530, Amit Kapila wrote: >> Won't in theory the similar cache in transam.c is also prone to >> similar behavior? TransactionIdDidCommit() and TransactionIdDidAbort() are used in much more code paths for visibility purposes, contrary to the subtrans.c ones. > It's not quite the same risk, because there we are likely to actually hit the > cache regularly. Whereas quite normal workloads might not hit this cache for > days on end. Yeah. In short, this mostly depends on the use of savepoints and the number of XIDs issued until PGPROC_MAX_CACHED_SUBXIDS is reached, and a single cache entry in this code path would reduce the pressure on the SLRU lookups depending on the number of queries issued, for example. One thing I know of that likes to abuse of savepoints and could cause overflows to make this easier to hit is the ODBC driver coupled with short queries in long transactions, where its internals enforce the use of a savepoint each time a query is issued by an application (pretty much what the benchmark at the top of the thread does). In this case, even the single cache approach would not help much because I recall that we finish with one savepoint per query to be able to rollback to any previous state within a given transaction (as the ODBC APIs allow). Doing a caching within SubTransGetParent() would be more interesting, for sure, though the invalidation to clean the cache and to make that robust enough may prove tricky. It took me some time to come back to this thread. The change has now been reverted. -- Michael
Commits
-
Revert "Add single-item cache when looking at topmost XID of a subtrans XID"
- b4529005fd38 15.0 landed
-
Add single-item cache when looking at topmost XID of a subtrans XID
- 06f5295af673 15.0 landed
-
Fix handling of partitioned index in RelationGetNumberOfBlocksInFork()
- 0d906b2c0b1f 15.0 cited