postgresql/src
Tom Lane 3d65b0593c Fix bogus cache-invalidation logic in logical replication worker.
The code recorded cache invalidation events by zeroing the "localreloid"
field of affected cache entries.  However, it's possible for an inval
event to occur even while we have the entry open and locked.  So an
ill-timed inval could result in "cache lookup failed for relation 0"
errors, if the worker's code tried to use the cleared field.  We can
fix that by creating a separate bool field to record whether the entry
needs to be revalidated.  (In the back branches, cram the bool into
what had been padding space, to avoid an ABI break in the somewhat
unlikely event that any extension is looking at this struct.)

Also, rearrange the logic in logicalrep_rel_open so that it
does the right thing in cases where table_open would fail.
We should retry the lookup by name in that case, but we didn't.

The real-world impact of this is probably small.  In the first place,
the error conditions are very low probability, and in the second place,
the worker would just exit and get restarted.  We only noticed because
in a CLOBBER_CACHE_ALWAYS build, the failure can occur repeatedly,
preventing the worker from making progress.  Nonetheless, it's clearly
a bug, and it impedes a useful type of testing; so back-patch to v10
where this code was introduced.

Discussion: https://postgr.es/m/1032727.1600096803@sss.pgh.pa.us
2020-09-16 12:07:31 -04:00
..
backend Fix bogus cache-invalidation logic in logical replication worker. 2020-09-16 12:07:31 -04:00
bin Avoid retrieval of CHECK constraints and DEFAULT exprs in data-only dump 2020-09-16 16:26:50 +09:00
common Skip unnecessary stat() calls in walkdir(). 2020-09-07 18:28:06 +12:00
fe_utils Message fixes and style improvements 2020-09-14 06:42:30 +02:00
include Fix bogus cache-invalidation logic in logical replication worker. 2020-09-16 12:07:31 -04:00
interfaces Add libpq's openssl dependencies to pkg-config file 2020-09-10 15:55:31 +02:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Remove unused parameter 2020-09-02 15:17:33 +02:00
port Add d_type to our Windows dirent emulation. 2020-09-07 23:38:19 +12:00
template Fix compiler warning for ppoll() on Cygwin 2019-12-22 23:20:00 +01:00
test Fix use-after-free bug with event triggers in an extension script 2020-09-15 21:03:14 -03:00
timezone Ensure that distributed timezone abbreviation files are plain ASCII. 2020-07-17 11:03:55 -04:00
tools New contrib module, pg_surgery, with heap surgery functions. 2020-09-10 11:14:07 -04:00
tutorial doc: Change table alias names to lower case in tutorial chapter 2020-09-04 08:45:57 +02:00
.gitignore
DEVELOPERS
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Split Makefile symbol CFLAGS_VECTOR into two symbols. 2020-09-06 21:28:16 -04:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00