]> granicus.if.org Git - postgresql/commit
Correct logical decoding restore behaviour for subtransactions.
authorAndres Freund <andres@anarazel.de>
Tue, 4 Oct 2016 05:11:36 +0000 (22:11 -0700)
committerAndres Freund <andres@anarazel.de>
Tue, 4 Oct 2016 05:13:10 +0000 (22:13 -0700)
commitce603a34a4568e876c0d9c826325d9b12c9e5497
treecd1a9940aced8cb408cf8aa7ac752f6fbb807195
parentf50fa46cca9a1e5bfd517f7f1d979ef4db55ce03
Correct logical decoding restore behaviour for subtransactions.

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
Reported-By: Huan Ruan
Discussion: <20160909012610.20024.58169@wrigleys.postgresql.org>
Backport: 9,4-, where logical decoding was added
contrib/test_decoding/Makefile
contrib/test_decoding/expected/spill.out [new file with mode: 0644]
contrib/test_decoding/sql/spill.sql [new file with mode: 0644]
src/backend/replication/logical/reorderbuffer.c