postgresql/src/backend/access
Tom Lane 10564ee02c Fix code for re-finding scan position in a multicolumn GIN index.
collectMatchBitmap() needs to re-find the index tuple it was previously
looking at, after transiently dropping lock on the index page it's on.
The tuple should still exist and be at its prior position or somewhere
to the right of that, since ginvacuum never removes tuples but
concurrent insertions could add one.  However, there was a thinko in
that logic, to the effect of expecting any inserted tuples to have the
same index "attnum" as what we'd been scanning.  Since there's no
physical separation of tuples with different attnums, it's not terribly
hard to devise scenarios where this fails, leading to transient "lost
saved point in index" errors.  (While I've duplicated this with manual
testing, it seems impossible to make a reproducible test case with our
available testing technology.)

Fix by just continuing the scan when the attnum doesn't match.

While here, improve the error message used if we do fail, so that it
matches the wording used in btree for a similar case.

collectMatchBitmap()'s posting-tree code path was previously not
exercised at all by our regression tests.  While I can't make
a regression test that exhibits the bug, I can at least improve
the code coverage here, so do that.  The test case I made for this
is an extension of one added by 4b754d6c1, so it only works in
HEAD and v13; didn't seem worth trying hard to back-patch it.

Per bug #16595 from Jesse Kinkead.  This has been broken since
multicolumn capability was added to GIN (commit 27cb66fdf),
so back-patch to all supported branches.

Discussion: https://postgr.es/m/16595-633118be8eef9ce2@postgresql.org
2020-08-27 17:36:13 -04:00
..
brin BRIN: Handle concurrent desummarization properly 2020-08-12 15:33:36 -04:00
common Move syncscan.c to src/backend/access/common. 2020-07-29 16:59:33 +12:00
gin Fix code for re-finding scan position in a multicolumn GIN index. 2020-08-27 17:36:13 -04:00
gist snapshot scalability: Move PGXACT->xmin back to PGPROC. 2020-08-13 16:25:21 -07:00
hash Invent "amadjustmembers" AM method for validating opclass members. 2020-08-01 17:12:47 -04:00
heap Add additional information in the vacuum error context. 2020-08-26 09:40:52 +05:30
index snapshot scalability: Don't compute global horizons while building snapshots. 2020-08-12 16:03:49 -07:00
nbtree snapshot scalability: Move PGXACT->xmin back to PGPROC. 2020-08-13 16:25:21 -07:00
rmgrdesc Rename VariableCacheData.nextFullXid to nextXid. 2020-08-11 12:07:14 -07:00
spgist snapshot scalability: Don't compute global horizons while building snapshots. 2020-08-12 16:03:49 -07:00
table Implement streaming mode in ReorderBuffer. 2020-08-08 07:47:06 +05:30
tablesample Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
transam Mark commit and abort WAL records with XLR_SPECIAL_REL_UPDATE. 2020-08-17 10:52:58 +03:00
Makefile Introduce access/{table.h, relation.h}, for generic functions from heapam.h. 2019-01-21 10:51:36 -08:00