From ff821d820630313e4dcea65aa1b35d47a0736c64 Mon Sep 17 00:00:00 2001 From: John Naylor Date: Tue, 5 Feb 2019 10:32:19 +0100 Subject: [PATCH v1 1/2] Improve FSM regression test In the interest of caution, in commit b0eaa4c51bb we left out a test that used vacuum to remove dead rows. This test has been rewritten to use fillfactor instead to control free space. Since we no longer need to remove dead rows as part of the test, put the fsm regression test in a parallel group. --- src/test/regress/expected/fsm.out | 25 ++++++++++++++++++++++--- src/test/regress/parallel_schedule | 8 +------- src/test/regress/sql/fsm.sql | 22 ++++++++++++++++++++-- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/test/regress/expected/fsm.out b/src/test/regress/expected/fsm.out index b02993188c..d747c1a7dd 100644 --- a/src/test/regress/expected/fsm.out +++ b/src/test/regress/expected/fsm.out @@ -2,14 +2,33 @@ -- Free Space Map test -- CREATE TABLE fsm_check_size (num int, str text); --- With one block, there should be no FSM -INSERT INTO fsm_check_size VALUES(1, 'a'); +-- Fill 3 blocks with one record each +ALTER TABLE fsm_check_size SET (fillfactor=15); +INSERT INTO fsm_check_size SELECT i, rpad('', 1024, 'a') +FROM generate_series(1,3) i; +-- There should be no FSM VACUUM fsm_check_size; SELECT pg_relation_size('fsm_check_size', 'main') AS heap_size, pg_relation_size('fsm_check_size', 'fsm') AS fsm_size; heap_size | fsm_size -----------+---------- - 8192 | 0 + 24576 | 0 +(1 row) + +-- Fill most of the last block +ALTER TABLE fsm_check_size SET (fillfactor=100); +INSERT INTO fsm_check_size SELECT i, rpad('', 1024, 'a') +FROM generate_series(101,105) i; +-- Make sure records can go into any block but the last one +ALTER TABLE fsm_check_size SET (fillfactor=30); +-- Insert large record and make sure it does not cause the relation to extend +INSERT INTO fsm_check_size VALUES (111, rpad('', 1024, 'a')); +VACUUM fsm_check_size; +SELECT pg_relation_size('fsm_check_size', 'main') AS heap_size, +pg_relation_size('fsm_check_size', 'fsm') AS fsm_size; + heap_size | fsm_size +-----------+---------- + 24576 | 0 (1 row) -- Extend table with enough blocks to exceed the FSM threshold diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule index 4051a4ad4e..a956775dd1 100644 --- a/src/test/regress/parallel_schedule +++ b/src/test/regress/parallel_schedule @@ -23,7 +23,7 @@ test: numerology # ---------- # The second group of parallel tests # ---------- -test: point lseg line box path polygon circle date time timetz timestamp timestamptz interval inet macaddr macaddr8 tstypes +test: point lseg line box path polygon circle date time timetz timestamp timestamptz interval inet macaddr macaddr8 tstypes fsm # ---------- # Another group of parallel tests @@ -68,12 +68,6 @@ test: create_aggregate create_function_3 create_cast constraints triggers inheri # ---------- test: sanity_check -# ---------- -# fsm does a delete followed by vacuum, and running it in parallel can prevent -# removal of rows. -# ---------- -test: fsm - # ---------- # Believe it or not, select creates a table, subsequent # tests need. diff --git a/src/test/regress/sql/fsm.sql b/src/test/regress/sql/fsm.sql index 332c3e2b2d..2f169c0508 100644 --- a/src/test/regress/sql/fsm.sql +++ b/src/test/regress/sql/fsm.sql @@ -4,8 +4,26 @@ CREATE TABLE fsm_check_size (num int, str text); --- With one block, there should be no FSM -INSERT INTO fsm_check_size VALUES(1, 'a'); +-- Fill 3 blocks with one record each +ALTER TABLE fsm_check_size SET (fillfactor=15); +INSERT INTO fsm_check_size SELECT i, rpad('', 1024, 'a') +FROM generate_series(1,3) i; + +-- There should be no FSM +VACUUM fsm_check_size; +SELECT pg_relation_size('fsm_check_size', 'main') AS heap_size, +pg_relation_size('fsm_check_size', 'fsm') AS fsm_size; + +-- Fill most of the last block +ALTER TABLE fsm_check_size SET (fillfactor=100); +INSERT INTO fsm_check_size SELECT i, rpad('', 1024, 'a') +FROM generate_series(101,105) i; + +-- Make sure records can go into any block but the last one +ALTER TABLE fsm_check_size SET (fillfactor=30); + +-- Insert large record and make sure it does not cause the relation to extend +INSERT INTO fsm_check_size VALUES (111, rpad('', 1024, 'a')); VACUUM fsm_check_size; SELECT pg_relation_size('fsm_check_size', 'main') AS heap_size, -- 2.17.1