|
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 | +if (!$node->check_extension('injection_points')) |
| 31 | +{ |
| 32 | + plan skip_all => 'Extension injection_points not installed'; |
| 33 | +} |
| 34 | + |
| 35 | +$node->safe_psql('postgres', q(CREATE EXTENSION injection_points)); |
33 | 36 |
|
34 | 37 | # Create the two slots we'll need.
|
35 | 38 | $node->safe_psql('postgres',
|
|
58 | 61 | \q
|
59 | 62 | ));
|
60 | 63 |
|
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 |
| -); |
| 64 | +$node->advance_wal(20); |
65 | 65 |
|
66 | 66 | # Run another checkpoint to set a new restore LSN.
|
67 | 67 | $node->safe_psql('postgres', q{checkpoint});
|
68 | 68 |
|
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 |
| -); |
| 69 | +$node->advance_wal(20); |
73 | 70 |
|
74 | 71 | # Run another checkpoint, this time in the background, and make it wait
|
75 | 72 | # on the injection point) so that the checkpoint stops right before
|
76 | 73 | # removing old WAL segments.
|
77 |
| -note('starting checkpoint\n'); |
| 74 | +note('starting checkpoint'); |
78 | 75 |
|
79 | 76 | my $checkpoint = $node->background_psql('postgres');
|
80 | 77 | $checkpoint->query_safe(
|
|
88 | 85 | ));
|
89 | 86 |
|
90 | 87 | # Wait until the checkpoint stops right before removing WAL segments.
|
91 |
| -note('waiting for injection_point\n'); |
| 88 | +note('waiting for injection_point'); |
92 | 89 | $node->wait_for_event('checkpointer', 'checkpoint-before-old-wal-removal');
|
93 | 90 | note('injection_point is reached');
|
94 | 91 |
|
|
107 | 104 | ));
|
108 | 105 |
|
109 | 106 | # Wait until the slot's restart_lsn points to the next WAL segment.
|
110 |
| -note('waiting for injection_point\n'); |
| 107 | +note('waiting for injection_point'); |
111 | 108 | $node->wait_for_event('client backend',
|
112 | 109 | 'logical-replication-slot-advance-segment');
|
113 | 110 | note('injection_point is reached');
|
|
0 commit comments