Paper over regression failures in infinite_recurse() on PPC64 Linux.
authorTom Lane <[email protected]>
Tue, 13 Oct 2020 21:44:56 +0000 (17:44 -0400)
committerTom Lane <[email protected]>
Tue, 13 Oct 2020 21:44:56 +0000 (17:44 -0400)
Our infinite_recurse() test to verify sane stack-overrun behavior
is affected by a bug of the Linux kernel on PPC64: it will get SIGSEGV
if it receives a signal when the stack depth is (a) over 1MB and
(b) within a few kB of filling the current physical stack allocation.
See https://bugzilla.kernel.org/show_bug.cgi?id=205183.

Since this test is a bit time-consuming and we run it in parallel with
test scripts that do a lot of DDL, it can be expected to get an sinval
catchup interrupt at some point, leading to failure if the timing is
wrong.  This has caused more than 100 buildfarm failures over the
past year or so.

While a fix exists for the kernel bug, it might be years before that
propagates into all production kernels, particularly in some of the
older distros we have in the buildfarm.  For now, let's just back off
and not run this test on Linux PPC64; that loses nothing in test
coverage so far as our own code is concerned.

To do that, split this test into a new script infinite_recurse.sql
and skip the test when the platform name is powerpc64...-linux-gnu.

Back-patch to v12.  Branches before that have not been seen to get
this failure.  No doubt that's because the "errors" test was not
run in parallel with other tests before commit 798070ec0, greatly
reducing the odds of an sinval catchup being necessary.

I also back-patched 3c8553547 into v12, just so the new regression
script would look the same in all branches having it.

Discussion: https://postgr.es/m/3479046.1602607848@sss.pgh.pa.us
Discussion: https://postgr.es/m/20190723162703.GM22387%40telsasoft.com

src/test/regress/expected/errors.out
src/test/regress/expected/infinite_recurse.out [new file with mode: 0644]
src/test/regress/expected/infinite_recurse_1.out [new file with mode: 0644]
src/test/regress/parallel_schedule
src/test/regress/serial_schedule
src/test/regress/sql/errors.sql
src/test/regress/sql/infinite_recurse.sql [new file with mode: 0644]

index a525aa2f93778cf66c0ca675ee0dd2f864a7a72c..1e7b5a70461978bc230d2a8043920ea39d64aa5d 100644 (file)
@@ -440,13 +440,3 @@ NULL);
 ERROR:  syntax error at or near "NUL"
 LINE 16: ...L, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 I...
                                                               ^
--- Check that stack depth detection mechanism works and
--- max_stack_depth is not set too high.  The full error report is not
--- very stable, so show only SQLSTATE and primary error message.
-create function infinite_recurse() returns int as
-'select infinite_recurse()' language sql;
-\set VERBOSITY sqlstate
-select infinite_recurse();
-ERROR:  54001
-\echo :LAST_ERROR_MESSAGE
-stack depth limit exceeded
diff --git a/src/test/regress/expected/infinite_recurse.out b/src/test/regress/expected/infinite_recurse.out
new file mode 100644 (file)
index 0000000..aa102fa
--- /dev/null
@@ -0,0 +1,24 @@
+-- Check that stack depth detection mechanism works and
+-- max_stack_depth is not set too high.
+create function infinite_recurse() returns int as
+'select infinite_recurse()' language sql;
+-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64
+-- signal handling that would cause this test to crash if it happened
+-- to receive an sinval catchup interrupt while the stack is deep:
+-- https://bugzilla.kernel.org/show_bug.cgi?id=205183
+-- It is likely to be many years before that bug disappears from all
+-- production kernels, so disable this test on such platforms.
+-- (We still create the function, so as not to have a cross-platform
+-- difference in the end state of the regression database.)
+SELECT version() ~ 'powerpc64[^,]*-linux-gnu'
+       AS skip_test \gset
+\if :skip_test
+\quit
+\endif
+-- The full error report is not very stable, so we show only SQLSTATE
+-- and primary error message.
+\set VERBOSITY sqlstate
+select infinite_recurse();
+ERROR:  54001
+\echo :LAST_ERROR_MESSAGE
+stack depth limit exceeded
diff --git a/src/test/regress/expected/infinite_recurse_1.out b/src/test/regress/expected/infinite_recurse_1.out
new file mode 100644 (file)
index 0000000..b2c99a0
--- /dev/null
@@ -0,0 +1,16 @@
+-- Check that stack depth detection mechanism works and
+-- max_stack_depth is not set too high.
+create function infinite_recurse() returns int as
+'select infinite_recurse()' language sql;
+-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64
+-- signal handling that would cause this test to crash if it happened
+-- to receive an sinval catchup interrupt while the stack is deep:
+-- https://bugzilla.kernel.org/show_bug.cgi?id=205183
+-- It is likely to be many years before that bug disappears from all
+-- production kernels, so disable this test on such platforms.
+-- (We still create the function, so as not to have a cross-platform
+-- difference in the end state of the regression database.)
+SELECT version() ~ 'powerpc64[^,]*-linux-gnu'
+       AS skip_test \gset
+\if :skip_test
+\quit
index 026ea880cde3a4ca6830050a810bf055887f517e..ae89ed7f0b40bd0a0213bdfef8b259074477220c 100644 (file)
@@ -55,7 +55,7 @@ test: create_index create_index_spgist create_view index_including index_includi
 # ----------
 # Another group of parallel tests
 # ----------
-test: create_aggregate create_function_3 create_cast constraints triggers select inherit typed_table vacuum drop_if_exists updatable_views roleattributes create_am hash_func errors
+test: create_aggregate create_function_3 create_cast constraints triggers select inherit typed_table vacuum drop_if_exists updatable_views roleattributes create_am hash_func errors infinite_recurse
 
 # ----------
 # sanity_check does a vacuum, affecting the sort order of SELECT *
index 979d9261197d35c50f61c3f5f51c7f69c10fc419..525bdc804f61286dd4baccf627ef8c8dea0e8fe0 100644 (file)
@@ -83,6 +83,7 @@ test: roleattributes
 test: create_am
 test: hash_func
 test: errors
+test: infinite_recurse
 test: sanity_check
 test: select_into
 test: select_distinct
index 86b672538a17a5b75be8c8b00d12fee698a0822f..66a56b28f62b8811dab73b5d3cb8b605b52cabb6 100644 (file)
@@ -364,12 +364,3 @@ INT4
 UNIQUE
 NOT
 NULL);
-
--- Check that stack depth detection mechanism works and
--- max_stack_depth is not set too high.  The full error report is not
--- very stable, so show only SQLSTATE and primary error message.
-create function infinite_recurse() returns int as
-'select infinite_recurse()' language sql;
-\set VERBOSITY sqlstate
-select infinite_recurse();
-\echo :LAST_ERROR_MESSAGE
diff --git a/src/test/regress/sql/infinite_recurse.sql b/src/test/regress/sql/infinite_recurse.sql
new file mode 100644 (file)
index 0000000..151dba4
--- /dev/null
@@ -0,0 +1,29 @@
+-- Check that stack depth detection mechanism works and
+-- max_stack_depth is not set too high.
+
+create function infinite_recurse() returns int as
+'select infinite_recurse()' language sql;
+
+-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64
+-- signal handling that would cause this test to crash if it happened
+-- to receive an sinval catchup interrupt while the stack is deep:
+-- https://bugzilla.kernel.org/show_bug.cgi?id=205183
+-- It is likely to be many years before that bug disappears from all
+-- production kernels, so disable this test on such platforms.
+-- (We still create the function, so as not to have a cross-platform
+-- difference in the end state of the regression database.)
+
+SELECT version() ~ 'powerpc64[^,]*-linux-gnu'
+       AS skip_test \gset
+\if :skip_test
+\quit
+\endif
+
+-- The full error report is not very stable, so we show only SQLSTATE
+-- and primary error message.
+
+\set VERBOSITY sqlstate
+
+select infinite_recurse();
+
+\echo :LAST_ERROR_MESSAGE