]> granicus.if.org Git - postgresql/commitdiff
Make PostgresNode.pm's poll_query_until() more chatty about failures.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 16 Oct 2018 16:32:28 +0000 (12:32 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 16 Oct 2018 16:32:28 +0000 (12:32 -0400)
Reporting only the stderr is unhelpful when the problem is that the
server output we're getting doesn't match what was expected.  So we
should report the query output too; and just for good measure, let's
print the query we used and the output we expected.

Back-patch to 9.5 where poll_query_until was introduced.

Discussion: https://postgr.es/m/17913.1539634756@sss.pgh.pa.us

src/bin/pg_rewind/RewindTest.pm

index 426bd6e5cf319a53f313d93f4a1bc014ce83286a..734adb72ec543b9351ff942e6b13436df4b819e5 100644 (file)
@@ -151,9 +151,18 @@ sub poll_query_until
                $attempts++;
        }
 
-       # The query result didn't change in 90 seconds. Give up. Print the stderr
-       # from the last attempt, hopefully that's useful for debugging.
-       diag $stderr;
+       # The query result didn't change in 90 seconds. Give up. Print the
+       # output from the last attempt, hopefully that's useful for debugging.
+       chomp($stderr);
+       $stderr =~ s/\r//g if $Config{osname} eq 'msys';
+       diag qq(poll_query_until timed out executing this query:
+$query
+expecting this output:
+t
+last actual query output:
+$stdout
+with stderr:
+$stderr);
        return 0;
 }