|
21 | 21 |
|
22 | 22 | $node = PostgreSQL::Test::Cluster->new('mike');
|
23 | 23 | $node->init;
|
24 |
| -$node->append_conf('postgresql.conf', |
25 |
| - "shared_preload_libraries = 'injection_points'"); |
26 | 24 | $node->append_conf('postgresql.conf', "wal_level = 'logical'");
|
27 | 25 | $node->start;
|
28 |
| -$node->safe_psql('postgres', q(CREATE EXTENSION injection_points)); |
29 | 26 |
|
30 |
| -# Create a simple table to generate data into. |
31 |
| -$node->safe_psql('postgres', |
32 |
| - q{create table t (id serial primary key, b text)}); |
| 27 | +# Check if the extension injection_points is available, as it may be |
| 28 | +# possible that this script is run with installcheck, where the module |
| 29 | +# would not be installed by default. |
| 30 | +$result = $node->safe_psql('postgres', |
| 31 | + "SELECT count(*) > 0 FROM pg_available_extensions WHERE name = 'injection_points';" |
| 32 | +); |
| 33 | +if ($result eq 'f') |
| 34 | +{ |
| 35 | + plan skip_all => 'Extension injection_points not installed'; |
| 36 | +} |
| 37 | + |
| 38 | +$node->safe_psql('postgres', q(CREATE EXTENSION injection_points)); |
33 | 39 |
|
34 | 40 | # Create the two slots we'll need.
|
35 | 41 | $node->safe_psql('postgres',
|
|
58 | 64 | \q
|
59 | 65 | ));
|
60 | 66 |
|
61 |
| -# Insert 2M rows; that's about 260MB (~20 segments) worth of WAL. |
62 |
| -$node->safe_psql('postgres', |
63 |
| - q{insert into t (b) select md5(i::text) from generate_series(1,1000000) s(i)} |
64 |
| -); |
| 67 | +$node->advance_wal(20); |
65 | 68 |
|
66 | 69 | # Run another checkpoint to set a new restore LSN.
|
67 | 70 | $node->safe_psql('postgres', q{checkpoint});
|
68 | 71 |
|
69 |
| -# Another 2M rows; that's about 260MB (~20 segments) worth of WAL. |
70 |
| -$node->safe_psql('postgres', |
71 |
| - q{insert into t (b) select md5(i::text) from generate_series(1,1000000) s(i)} |
72 |
| -); |
| 72 | +$node->advance_wal(20); |
73 | 73 |
|
74 | 74 | # Run another checkpoint, this time in the background, and make it wait
|
75 | 75 | # on the injection point) so that the checkpoint stops right before
|
76 | 76 | # removing old WAL segments.
|
77 |
| -note('starting checkpoint\n'); |
| 77 | +note('starting checkpoint'); |
78 | 78 |
|
79 | 79 | my $checkpoint = $node->background_psql('postgres');
|
80 | 80 | $checkpoint->query_safe(
|
|
88 | 88 | ));
|
89 | 89 |
|
90 | 90 | # Wait until the checkpoint stops right before removing WAL segments.
|
91 |
| -note('waiting for injection_point\n'); |
| 91 | +note('waiting for injection_point'); |
92 | 92 | $node->wait_for_event('checkpointer', 'checkpoint-before-old-wal-removal');
|
93 | 93 | note('injection_point is reached');
|
94 | 94 |
|
|
107 | 107 | ));
|
108 | 108 |
|
109 | 109 | # Wait until the slot's restart_lsn points to the next WAL segment.
|
110 |
| -note('waiting for injection_point\n'); |
| 110 | +note('waiting for injection_point'); |
111 | 111 | $node->wait_for_event('client backend',
|
112 | 112 | 'logical-replication-slot-advance-segment');
|
113 | 113 | note('injection_point is reached');
|
|
0 commit comments