|
15 | 15 | umask(0077); |
16 | 16 |
|
17 | 17 | my $primary = PostgreSQL::Test::Cluster->new('primary'); |
18 | | -$primary->init(allows_streaming => 1); |
| 18 | +$primary->init(allows_streaming => 1, extra => ['--wal-segsize=1']); |
19 | 19 | $primary->start; |
20 | 20 |
|
21 | 21 | my $stream_dir = $primary->basedir . '/archive_wal'; |
|
50 | 50 | # Generate some WAL. Use --synchronous at the same time to add more |
51 | 51 | # code coverage. Switch to the next segment first so that subsequent |
52 | 52 | # restarts of pg_receivewal will see this segment as full.. |
53 | | -$primary->psql('postgres', 'CREATE TABLE test_table(x integer);'); |
| 53 | +$primary->psql('postgres', 'CREATE TABLE test_table(x integer PRIMARY KEY);'); |
54 | 54 | $primary->psql('postgres', 'SELECT pg_switch_wal();'); |
55 | 55 | my $nextlsn = |
56 | 56 | $primary->safe_psql('postgres', 'SELECT pg_current_wal_insert_lsn();'); |
57 | 57 | chomp($nextlsn); |
58 | | -$primary->psql('postgres', |
59 | | - 'INSERT INTO test_table VALUES (generate_series(1,100));'); |
| 58 | +$primary->psql('postgres', 'INSERT INTO test_table VALUES (1);'); |
60 | 59 |
|
61 | 60 | # Stream up to the given position. This is necessary to have a fixed |
62 | 61 | # started point for the next commands done in this test, with or without |
|
85 | 84 | $nextlsn = |
86 | 85 | $primary->safe_psql('postgres', 'SELECT pg_current_wal_insert_lsn();'); |
87 | 86 | chomp($nextlsn); |
88 | | - $primary->psql('postgres', |
89 | | - 'INSERT INTO test_table VALUES (generate_series(100,200));'); |
| 87 | + $primary->psql('postgres', 'INSERT INTO test_table VALUES (2);'); |
90 | 88 |
|
91 | 89 | # Note the trailing whitespace after the value of --compress, that is |
92 | 90 | # a valid value. |
|
136 | 134 | $nextlsn = |
137 | 135 | $primary->safe_psql('postgres', 'SELECT pg_current_wal_insert_lsn();'); |
138 | 136 | chomp($nextlsn); |
139 | | -$primary->psql('postgres', |
140 | | - 'INSERT INTO test_table VALUES (generate_series(200,300));'); |
| 137 | +$primary->psql('postgres', 'INSERT INTO test_table VALUES (3);'); |
141 | 138 | $primary->command_ok( |
142 | 139 | [ |
143 | 140 | 'pg_receivewal', '-D', $stream_dir, '--verbose', |
|
167 | 164 | $slot_name = 'archive_slot'; |
168 | 165 |
|
169 | 166 | # Setup the slot, reserving WAL at creation (corresponding to the |
170 | | -# last redo LSN here, actually). |
| 167 | +# last redo LSN here, actually, so use a checkpoint to reduce the |
| 168 | +# number of segments archived). |
| 169 | +$primary->psql('postgres', 'checkpoint;'); |
171 | 170 | $primary->psql('postgres', |
172 | 171 | "SELECT pg_create_physical_replication_slot('$slot_name', true);"); |
173 | 172 |
|
|
181 | 180 |
|
182 | 181 | # Switch to a new segment, to make sure that the segment retained by the |
183 | 182 | # slot is still streamed. This may not be necessary, but play it safe. |
184 | | -$primary->psql('postgres', |
185 | | - 'INSERT INTO test_table VALUES (generate_series(1,100));'); |
| 183 | +$primary->psql('postgres', 'INSERT INTO test_table VALUES (4);'); |
186 | 184 | $primary->psql('postgres', 'SELECT pg_switch_wal();'); |
187 | 185 | $nextlsn = |
188 | 186 | $primary->safe_psql('postgres', 'SELECT pg_current_wal_insert_lsn();'); |
189 | 187 | chomp($nextlsn); |
190 | 188 |
|
| 189 | +# Add a bit more data to accelerate the end of the next pg_receivewal |
| 190 | +# commands. |
| 191 | +$primary->psql('postgres', 'INSERT INTO test_table VALUES (5);'); |
| 192 | + |
191 | 193 | # Check case where the slot does not exist. |
192 | 194 | $primary->command_fails_like( |
193 | 195 | [ |
|
0 commit comments