diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-06-28 22:11:12 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-06-28 22:11:12 -0400 |
commit | 08aed6604de2e6a9f4d499818d7c641cbf5eb9f7 (patch) | |
tree | 72f79af03788563479aa291f2a301b284951f11e | |
parent | 1ae8536545b7ea486dbe15247e6dd817ee211297 (diff) | |
download | postgresql-08aed6604de2e6a9f4d499818d7c641cbf5eb9f7.tar.gz postgresql-08aed6604de2e6a9f4d499818d7c641cbf5eb9f7.zip |
Eat XIDs more efficiently in recovery TAP test.
The point of this loop is to insert 1000 rows into the test table
and consume 1000 XIDs. I can't see any good reason why it's useful
to launch 1000 psqls and 1000 backend processes to accomplish that.
Pushing the looping into a plpgsql DO block shaves about 10 seconds
off the runtime of the src/test/recovery TAP tests on my machine;
that's over 10% of the runtime of that test suite.
It is, in fact, sufficiently more efficient that we now demonstrably
need wait_slot_xmins() afterwards, or the slaves' xmins may not have
moved yet.
-rw-r--r-- | src/test/recovery/t/001_stream_rep.pl | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/test/recovery/t/001_stream_rep.pl b/src/test/recovery/t/001_stream_rep.pl index 750e40c3daf..c55497d61aa 100644 --- a/src/test/recovery/t/001_stream_rep.pl +++ b/src/test/recovery/t/001_stream_rep.pl @@ -224,19 +224,33 @@ isnt($xmin, '', 'xmin of cascaded slot non-null with hs feedback'); is($catalog_xmin, '', 'catalog xmin of cascaded slot still null with hs_feedback'); note "doing some work to advance xmin"; -for my $i (10000 .. 11000) -{ - $node_master->safe_psql('postgres', qq[INSERT INTO tab_int VALUES ($i);]); -} +$node_master->safe_psql('postgres', q{ +do $$ +begin + for i in 10000..11000 loop + -- use an exception block so that each iteration eats an XID + begin + insert into tab_int values (i); + exception + when division_by_zero then null; + end; + end loop; +end$$; +}); + $node_master->safe_psql('postgres', 'VACUUM;'); $node_master->safe_psql('postgres', 'CHECKPOINT;'); +wait_slot_xmins($node_master, $slotname_1, "xmin <> '$xmin'"); + my ($xmin2, $catalog_xmin2) = get_slot_xmins($node_master, $slotname_1); note "new xmin $xmin2, old xmin $xmin"; isnt($xmin2, $xmin, 'xmin of non-cascaded slot with hs feedback has changed'); is($catalog_xmin2, '', 'catalog xmin of non-cascaded slot still null with hs_feedback unchanged'); +wait_slot_xmins($node_standby_1, $slotname_2, "xmin <> '$xmin'"); + ($xmin2, $catalog_xmin2) = get_slot_xmins($node_standby_1, $slotname_2); note "new xmin $xmin2, old xmin $xmin"; isnt($xmin2, $xmin, 'xmin of cascaded slot with hs feedback has changed'); |