pgsql: Fix and improve cache invalidation logic for logical decoding.

Поиск
Список
Период
Сортировка
От Andres Freund
Тема pgsql: Fix and improve cache invalidation logic for logical decoding.
Дата
Msg-id E1Xp0J6-0000XW-H2@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix and improve cache invalidation logic for logical decoding.

There are basically three situations in which logical decoding needs
to perform cache invalidation. During/After replaying a transaction
with catalog changes, when skipping a uninteresting transaction that
performed catalog changes and when erroring out while replaying a
transaction. Unfortunately these three cases were all done slightly
differently - partially because 8de3e410fa, which greatly simplifies
matters, got committed in the midst of the development of logical
decoding.

The actually problematic case was when logical decoding skipped
transaction commits (and thus processed invalidations). When used via
the SQL interface cache invalidation could access the catalog - bad,
because we didn't set up enough state to allow that correctly. It'd
not be hard to setup sufficient state, but the simpler solution is to
always perform cache invalidation outside a valid transaction.

Also make the different cache invalidation cases look as similar as
possible, to ease code review.

This fixes the assertion failure reported by Antonin Houska in
53EE02D9.7040702@gmail.com. The presented testcase has been expanded
into a regression test.

Backpatch to 9.4, where logical decoding was introduced.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/89fd41b390a46202937f647043043d5b0a4eadae

Modified Files
--------------
contrib/test_decoding/Makefile                     |    2 +-
.../test_decoding/expected/decoding_into_rel.out   |   84 ++++++++++++++++++++
contrib/test_decoding/sql/decoding_into_rel.sql    |   27 +++++++
src/backend/replication/logical/reorderbuffer.c    |   81 ++++++++++---------
4 files changed, 152 insertions(+), 42 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: pgsql: Fix xmin/xmax horizon computation during logical decoding initia
Следующее
От: Andres Freund
Дата:
Сообщение: pgsql: Fix xmin/xmax horizon computation during logical decoding initia