postgresql/src/backend
Robert Haas 11c1239881 Fix broken snapshot handling in parallel workers.
Pengchengliu reported an assertion failure in a parallel woker while
performing a parallel scan using an overflowed snapshot. The proximate
cause is that TransactionXmin was set to an incorrect value.  The
underlying cause is incorrect snapshot handling in parallel.c.

In particular, InitializeParallelDSM() was unconditionally calling
GetTransactionSnapshot(), because I (rhaas) mistakenly thought that
was always retrieving an existing snapshot whereas, at isolation
levels less than REPEATABLE READ, it's actually taking a new one. So
instead do this only at higher isolation levels where there actually
is a single snapshot for the whole transaction.

By itself, this is not a sufficient fix, because we still need to
guarantee that TransactionXmin gets set properly in the workers. The
easiest way to do that seems to be to install the leader's active
snapshot as the transaction snapshot if the leader did not serialize a
transaction snapshot. This doesn't affect the results of future
GetTrasnactionSnapshot() calls since those have to take a new snapshot
anyway; what we care about is the side effect of setting TransactionXmin.

Report by Pengchengliu. Patch by Greg Nancarrow, except for some comment
text which I supplied.

Discussion: https://postgr.es/m/002f01d748ac$eaa781a0$bff684e0$@tju.edu.cn
2021-08-25 08:33:53 -04:00
..
access Fix broken snapshot handling in parallel workers. 2021-08-25 08:33:53 -04:00
bootstrap Rethink definition of pg_attribute.attcompression. 2021-05-27 13:24:27 -04:00
catalog Fix toast rewrites in logical decoding. 2021-08-25 10:10:50 +05:30
commands Fix toast rewrites in logical decoding. 2021-08-25 10:10:50 +05:30
executor Improve error messages about misuse of SELECT INTO. 2021-08-21 10:22:14 -04:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit jit: Don't inline functions that access thread-locals. 2021-07-22 15:08:10 +12:00
lib Fix typo in comment 2021-04-20 14:35:16 +02:00
libpq Set type identifier on BIO 2021-08-17 14:30:25 +02:00
main Update copyright for 2021 2021-01-02 13:06:25 -05:00
nodes Change the name of the Result Cache node to Memoize 2021-07-14 12:45:00 +12:00
optimizer Fix incorrect comment for get_agg_clause_costs 2021-07-26 14:56:09 +12:00
parser Avoid using ambiguous word "positive" in error message. 2021-08-25 11:47:43 +09:00
partitioning Avoid using ambiguous word "non-negative" in error messages. 2021-07-28 01:21:35 +09:00
po Translation updates 2021-08-09 11:51:59 +02:00
port Make EXEC_BACKEND more convenient on macOS. 2021-08-13 11:11:59 +12:00
postmaster Avoid creating archive status ".ready" files too early 2021-08-23 15:50:35 -04:00
regex Fix regexp misbehavior with capturing parens inside "{0}". 2021-08-24 16:37:27 -04:00
replication Fix backup manifests to generate correct WAL-Ranges across timelines 2021-08-23 11:09:54 +09:00
rewrite Reject cases where a query in WITH rewrites to just NOTIFY. 2021-07-09 11:02:26 -04:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Error message refactoring 2021-06-27 09:41:16 +02:00
storage Deduplicate choice of horizon for a relation procarray.c. 2021-07-24 20:30:26 -07:00
tcop Use elog, not Assert, to report failure to provide an outer snapshot. 2021-07-31 11:50:14 -04:00
tsearch Fix typos and grammar in comments and docs 2021-04-19 11:32:30 +09:00
utils Improve error message about valid value for distance in phrase operator. 2021-08-25 11:45:12 +09:00
.gitignore
common.mk
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
nls.mk Translation updates 2021-05-10 14:36:21 +02:00