mirror of
https://github.com/postgres/postgres.git
synced 2025-11-18 02:02:55 +03:00
Avoid race in RelationBuildDesc() affecting CREATE INDEX CONCURRENTLY.
CIC and REINDEX CONCURRENTLY assume backends see their catalog changes no later than each backend's next transaction start. That failed to hold when a backend absorbed a relevant invalidation in the middle of running RelationBuildDesc() on the CIC index. Queries that use the resulting index can silently fail to find rows. Fix this for future index builds by making RelationBuildDesc() loop until it finishes without accepting a relevant invalidation. It may be necessary to reindex to recover from past occurrences; REINDEX CONCURRENTLY suffices. Back-patch to 9.6 (all supported versions). Noah Misch and Andrey Borodin, reviewed (in earlier versions) by Andres Freund. Discussion: https://postgr.es/m/20210730022548.GA1940096@gust.leadboat.com
This commit is contained in:
@@ -415,4 +415,47 @@ sub command_fails_like
|
||||
like($stderr, $expected_stderr, "$test_name: matches");
|
||||
}
|
||||
|
||||
# Run a command and check its status and outputs.
|
||||
# The 5 arguments are:
|
||||
# - cmd: ref to list for command, options and arguments to run
|
||||
# - ret: expected exit status
|
||||
# - out: ref to list of re to be checked against stdout (all must match)
|
||||
# - err: ref to list of re to be checked against stderr (all must match)
|
||||
# - test_name: name of test
|
||||
sub command_checks_all
|
||||
{
|
||||
my ($cmd, $expected_ret, $out, $err, $test_name) = @_;
|
||||
|
||||
# run command
|
||||
my ($stdout, $stderr);
|
||||
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
||||
IPC::Run::run($cmd, '>', \$stdout, '2>', \$stderr);
|
||||
|
||||
# See http://perldoc.perl.org/perlvar.html#%24CHILD_ERROR
|
||||
my $ret = $?;
|
||||
die "command exited with signal " . ($ret & 127)
|
||||
if $ret & 127;
|
||||
$ret = $ret >> 8;
|
||||
|
||||
foreach ($stderr, $stdout) { s/\r\n/\n/g if $Config{osname} eq 'msys'; }
|
||||
|
||||
# check status
|
||||
ok($ret == $expected_ret,
|
||||
"$test_name status (got $ret vs expected $expected_ret)");
|
||||
|
||||
# check stdout
|
||||
for my $re (@$out)
|
||||
{
|
||||
like($stdout, $re, "$test_name stdout /$re/");
|
||||
}
|
||||
|
||||
# check stderr
|
||||
for my $re (@$err)
|
||||
{
|
||||
like($stderr, $re, "$test_name stderr /$re/");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user