|
77 | 77 | ok( $stderr =~ /timed out while waiting for target LSN/,
|
78 | 78 | "get timeout on waiting for unreachable LSN");
|
79 | 79 |
|
| 80 | +# 4. Check that pg_wal_replay_wait() triggers an error if called on primary, |
| 81 | +# within another function, or inside a transaction with an isolation level |
| 82 | +# higher than READ COMMITTED. |
80 | 83 |
|
81 |
| -# 4. Also, check the scenario of multiple LSN waiters. We make 5 background |
| 84 | +$node_primary->psql( |
| 85 | + 'postgres', |
| 86 | + "CALL pg_wal_replay_wait('${lsn3}');", |
| 87 | + stderr => \$stderr); |
| 88 | +ok( $stderr =~ /recovery is not in progress/, |
| 89 | + "get an error when running on the primary"); |
| 90 | + |
| 91 | +$node_standby1->psql( |
| 92 | + 'postgres', |
| 93 | + "BEGIN ISOLATION LEVEL REPEATABLE READ; CALL pg_wal_replay_wait('${lsn3}');", |
| 94 | + stderr => \$stderr); |
| 95 | +ok( $stderr =~ |
| 96 | + /pg_wal_replay_wait\(\) must be only called without an active or registered snapshot/, |
| 97 | + "get an error when running in a transaction with an isolation level higher than REPEATABLE READ" |
| 98 | +); |
| 99 | + |
| 100 | +$node_primary->safe_psql( |
| 101 | + 'postgres', qq[ |
| 102 | +CREATE FUNCTION pg_wal_replay_wait_wrap(target_lsn pg_lsn) RETURNS void AS \$\$ |
| 103 | + BEGIN |
| 104 | + CALL pg_wal_replay_wait(target_lsn); |
| 105 | + END |
| 106 | +\$\$ |
| 107 | +LANGUAGE plpgsql; |
| 108 | +]); |
| 109 | + |
| 110 | +$node_primary->wait_for_catchup($node_standby1); |
| 111 | +$node_standby1->psql( |
| 112 | + 'postgres', |
| 113 | + "SELECT pg_wal_replay_wait_wrap('${lsn3}');", |
| 114 | + stderr => \$stderr); |
| 115 | +ok( $stderr =~ |
| 116 | + /pg_wal_replay_wait\(\) must be only called without an active or registered snapshot/, |
| 117 | + "get an error when running within another function"); |
| 118 | + |
| 119 | +# 5. Also, check the scenario of multiple LSN waiters. We make 5 background |
82 | 120 | # psql sessions each waiting for a corresponding insertion. When waiting is
|
83 | 121 | # finished, stored procedures logs if there are visible as many rows as
|
84 | 122 | # should be.
|
|
124 | 162 |
|
125 | 163 | ok(1, 'multiple LSN waiters reported consistent data');
|
126 | 164 |
|
127 |
| -# 5. Check that the standby promotion terminates the wait on LSN. Start |
| 165 | +# 6. Check that the standby promotion terminates the wait on LSN. Start |
128 | 166 | # waiting for an unreachable LSN then promote. Check the log for the relevant
|
129 | 167 | # error message. Also, check that waiting for already replayed LSN doesn't
|
130 | 168 | # cause an error even after promotion.
|
|
0 commit comments