postgresql/src/backend/replication/logical
Tom Lane 3e3f8f2020 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
..
decode.c Represent command completion tags as structs 2020-03-02 18:19:51 -03:00
launcher.c Fix signal handler setup for SIGHUP in the apply launcher process. 2020-07-17 08:43:06 +05:30
logical.c Fix instance of elog() called while holding a spinlock 2020-06-04 10:17:49 +09:00
logicalfuncs.c Rework XLogReader callback system 2020-05-08 15:40:11 -04:00
Makefile Split all OBJS style lines in makefiles into one-line-per-entry style. 2019-11-05 14:41:07 -08:00
message.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
origin.c Spelling adjustments 2020-06-07 15:06:51 +02:00
proto.c Remove incorrect assertion for INSERT in logical replication's publisher 2020-01-12 22:43:45 +09:00
relation.c Fix bogus cache-invalidation logic in logical replication worker. 2020-09-16 12:07:31 -04:00
reorderbuffer.c Revert "Track statistics for spilling of changes from ReorderBuffer". 2020-07-13 08:46:56 +05:30
snapbuild.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tablesync.c Add logical replication support to replicate into partitioned tables 2020-04-06 15:15:52 +02:00
worker.c Fix over-eager ping'ing in logical replication receiver. 2020-09-04 20:33:37 -04:00