|
18 | 18 | $node->init;
|
19 | 19 | $node->append_conf(
|
20 | 20 | 'postgresql.conf', qq[
|
21 |
| -autovacuum = off # run autovacuum only when to anti wraparound |
22 | 21 | autovacuum_naptime = 1s
|
23 | 22 | # so it's easier to verify the order of operations
|
24 | 23 | autovacuum_max_workers = 1
|
|
27 | 26 | $node->start;
|
28 | 27 | $node->safe_psql('postgres', 'CREATE EXTENSION xid_wraparound');
|
29 | 28 |
|
30 |
| -# Create tables for a few different test scenarios |
| 29 | +# Create tables for a few different test scenarios. We disable autovacuum |
| 30 | +# on these tables to run it only to prevent wraparound. |
31 | 31 | $node->safe_psql(
|
32 | 32 | 'postgres', qq[
|
33 |
| -CREATE TABLE large(id serial primary key, data text, filler text default repeat(random()::text, 10)); |
| 33 | +CREATE TABLE large(id serial primary key, data text, filler text default repeat(random()::text, 10)) |
| 34 | + WITH (autovacuum_enabled = off); |
34 | 35 | INSERT INTO large(data) SELECT generate_series(1,30000);
|
35 | 36 |
|
36 |
| -CREATE TABLE large_trunc(id serial primary key, data text, filler text default repeat(random()::text, 10)); |
| 37 | +CREATE TABLE large_trunc(id serial primary key, data text, filler text default repeat(random()::text, 10)) |
| 38 | + WITH (autovacuum_enabled = off); |
37 | 39 | INSERT INTO large_trunc(data) SELECT generate_series(1,30000);
|
38 | 40 |
|
39 |
| -CREATE TABLE small(id serial primary key, data text, filler text default repeat(random()::text, 10)); |
| 41 | +CREATE TABLE small(id serial primary key, data text, filler text default repeat(random()::text, 10)) |
| 42 | + WITH (autovacuum_enabled = off); |
40 | 43 | INSERT INTO small(data) SELECT generate_series(1,15000);
|
41 | 44 |
|
42 |
| -CREATE TABLE small_trunc(id serial primary key, data text, filler text default repeat(random()::text, 10)); |
| 45 | +CREATE TABLE small_trunc(id serial primary key, data text, filler text default repeat(random()::text, 10)) |
| 46 | + WITH (autovacuum_enabled = off); |
43 | 47 | INSERT INTO small_trunc(data) SELECT generate_series(1,15000);
|
44 |
| -
|
45 |
| -CREATE TABLE autovacuum_disabled(id serial primary key, data text) WITH (autovacuum_enabled=false); |
46 |
| -INSERT INTO autovacuum_disabled(data) SELECT generate_series(1,1000); |
47 | 48 | ]);
|
48 | 49 |
|
49 | 50 | # Bump the query timeout to avoid false negatives on slow test systems.
|
|
63 | 64 | DELETE FROM large_trunc WHERE id > 10000;
|
64 | 65 | DELETE FROM small WHERE id % 2 = 0;
|
65 | 66 | DELETE FROM small_trunc WHERE id > 1000;
|
66 |
| - DELETE FROM autovacuum_disabled WHERE id % 2 = 0; |
67 | 67 | ]);
|
68 | 68 |
|
69 | 69 | # Consume 2 billion XIDs, to get us very close to wraparound
|
|
107 | 107 | 'postgres', qq[
|
108 | 108 | SELECT relname, age(relfrozenxid) > current_setting('autovacuum_freeze_max_age')::int
|
109 | 109 | FROM pg_class
|
110 |
| -WHERE relname IN ('large', 'large_trunc', 'small', 'small_trunc', 'autovacuum_disabled') |
| 110 | +WHERE relname IN ('large', 'large_trunc', 'small', 'small_trunc') |
111 | 111 | ORDER BY 1
|
112 | 112 | ]);
|
113 | 113 |
|
114 |
| -is( $ret, "autovacuum_disabled|f |
115 |
| -large|f |
| 114 | +is( $ret, "large|f |
116 | 115 | large_trunc|f
|
117 | 116 | small|f
|
118 | 117 | small_trunc|f", "all tables are vacuumed");
|
119 | 118 |
|
120 | 119 | # Check if vacuum failsafe was triggered for each table.
|
121 | 120 | my $log_contents = slurp_file($node->logfile, $log_offset);
|
122 |
| -foreach my $tablename ('large', 'large_trunc', 'small', 'small_trunc', |
123 |
| - 'autovacuum_disabled') |
| 121 | +foreach my $tablename ('large', 'large_trunc', 'small', 'small_trunc') |
124 | 122 | {
|
125 | 123 | like(
|
126 | 124 | $log_contents,
|
|
0 commit comments