Correct logical decoding restore behaviour for subtransactions

Enterprise / PostgreSQL - Andres Freund [anarazel.de] - 4 October 2016 00:11 UTC

Before initializing iteration over a subtransaction's changes, the last few changes were not spilled to disk. That's correct if the transaction didn't spill to disk, but otherwise... This bug can lead to missed or misorderd subtransaction contents when they were spilled to disk.

Move spilling of the remaining in-memory changes to ReorderBufferIterTXNInit(), where it can easily be applied to the top transaction and, if present, subtransactions.

Since this code had too many bugs already, noticeably increase test coverage.

Fixes: #14319

61633f7 Correct logical decoding restore behaviour for subtransactions.
contrib/test_decoding/Makefile | 3 +-
contrib/test_decoding/expected/spill.out | 256 +++++++++++++++++++++++
contrib/test_decoding/sql/spill.sql | 179 ++++++++++++++++
src/backend/replication/logical/reorderbuffer.c | 13 +-
4 files changed, 445 insertions(+), 6 deletions(-)

Upstream: git.postgresql.org


  • Share