summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAndres Freund2019-05-01 00:45:32 +0000
committerAndres Freund2019-05-01 00:45:32 +0000
commit809c9b48f4bdd11dfc088f6d0b9a6c57936c32ca (patch)
treeb4defe4f5ff319860f296cd527ae1fa3bf754a87 /src/test
parent4b40d40b30ae04ba524cd410f14e64ae4425a180 (diff)
Run catalog reindexing test from 3dbb317d32 serially, to avoid deadlocks.
The tests turn out to cause deadlocks in some circumstances. Fairly reproducibly so with -DRELCACHE_FORCE_RELEASE -DCATCACHE_FORCE_RELEASE. Some of the deadlocks may be hard to fix without disproportionate measures, but others probably should be fixed - but not in 12. We discussed removing the new tests until we can fix the issues underlying the deadlocks, but results from buildfarm animal markhor (which runs with CLOBBER_CACHE_ALWAYS) indicates that there might be a more severe, as of yet undiagnosed, issue (including on stable branches) with reindexing catalogs. The failure is: ERROR: could not read block 0 in file "base/16384/28025": read only 0 of 8192 bytes Therefore it seems advisable to keep the tests. It's not certain that running the tests in isolation removes the risk of deadlocks. It's possible that additional locks are needed to protect against a concurrent auto-analyze or such. Per discussion with Tom Lane. Discussion: https://postgr.es/m/[email protected] Backpatch: 9.4-, like 3dbb317d3
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/create_index.out18
-rw-r--r--src/test/regress/expected/reindex_catalog.out33
-rw-r--r--src/test/regress/parallel_schedule5
-rw-r--r--src/test/regress/serial_schedule1
-rw-r--r--src/test/regress/sql/create_index.sql21
-rw-r--r--src/test/regress/sql/reindex_catalog.sql36
6 files changed, 75 insertions, 39 deletions
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out
index ef8c8cd654d..326dc441776 100644
--- a/src/test/regress/expected/create_index.out
+++ b/src/test/regress/expected/create_index.out
@@ -1939,24 +1939,6 @@ INFO: index "reindex_verbose_pkey" was reindexed
\set VERBOSITY default
DROP TABLE reindex_verbose;
--
--- check that system tables can be reindexed
---
--- whole tables
-REINDEX TABLE pg_class; -- mapped, non-shared, critical
-REINDEX TABLE pg_index; -- non-mapped, non-shared, critical
-REINDEX TABLE pg_operator; -- non-mapped, non-shared, critical
-REINDEX TABLE pg_database; -- mapped, shared, critical
-REINDEX TABLE pg_shdescription; -- mapped, shared non-critical
--- Check that individual system indexes can be reindexed. That's a bit
--- different from the entire-table case because reindex_relation
--- treats e.g. pg_class special.
-REINDEX INDEX pg_class_oid_index; -- mapped, non-shared, critical
-REINDEX INDEX pg_class_relname_nsp_index; -- mapped, non-shared, non-critical
-REINDEX INDEX pg_index_indexrelid_index; -- non-mapped, non-shared, critical
-REINDEX INDEX pg_index_indrelid_index; -- non-mapped, non-shared, non-critical
-REINDEX INDEX pg_database_oid_index; -- mapped, shared, critical
-REINDEX INDEX pg_shdescription_o_c_index; -- mapped, shared, non-critical
---
-- REINDEX CONCURRENTLY
--
CREATE TABLE concur_reindex_tab (c1 int);
diff --git a/src/test/regress/expected/reindex_catalog.out b/src/test/regress/expected/reindex_catalog.out
new file mode 100644
index 00000000000..142616fccbb
--- /dev/null
+++ b/src/test/regress/expected/reindex_catalog.out
@@ -0,0 +1,33 @@
+--
+-- Check that system tables can be reindexed.
+--
+-- Note that this test currently has to run without parallel tests
+-- being scheduled, as currently reindex catalog tables can cause
+-- deadlocks:
+--
+-- * The lock upgrade between the ShareLock acquired for the reindex
+-- and RowExclusiveLock needed for pg_class/pg_index locks can
+-- trigger deadlocks.
+--
+-- * The uniqueness checks performed when reindexing a unique/primary
+-- key index possibly need to wait for the transaction of a
+-- about-to-deleted row in pg_class to commit. That can cause
+-- deadlocks because, in contrast to user tables, locks on catalog
+-- tables are routinely released before commit - therefore the lock
+-- held for reindexing doesn't guarantee that no running transaction
+-- performed modifications in the table underlying the index.
+-- Check reindexing of whole tables
+REINDEX TABLE pg_class; -- mapped, non-shared, critical
+REINDEX TABLE pg_index; -- non-mapped, non-shared, critical
+REINDEX TABLE pg_operator; -- non-mapped, non-shared, critical
+REINDEX TABLE pg_database; -- mapped, shared, critical
+REINDEX TABLE pg_shdescription; -- mapped, shared non-critical
+-- Check that individual system indexes can be reindexed. That's a bit
+-- different from the entire-table case because reindex_relation
+-- treats e.g. pg_class special.
+REINDEX INDEX pg_class_oid_index; -- mapped, non-shared, critical
+REINDEX INDEX pg_class_relname_nsp_index; -- mapped, non-shared, non-critical
+REINDEX INDEX pg_index_indexrelid_index; -- non-mapped, non-shared, critical
+REINDEX INDEX pg_index_indrelid_index; -- non-mapped, non-shared, non-critical
+REINDEX INDEX pg_database_oid_index; -- mapped, shared, critical
+REINDEX INDEX pg_shdescription_o_c_index; -- mapped, shared, non-critical
diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule
index 8229e10909d..3b7759b6faa 100644
--- a/src/test/regress/parallel_schedule
+++ b/src/test/regress/parallel_schedule
@@ -53,6 +53,11 @@ test: create_misc create_operator create_procedure
test: create_index create_index_spgist create_view index_including index_including_gist
# ----------
+# Has to run in isolation, due to deadlock risk
+# ----------
+test: reindex_catalog
+
+# ----------
# 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 rolenames roleattributes create_am hash_func errors
diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule
index 9839087faa1..43523c6fc62 100644
--- a/src/test/regress/serial_schedule
+++ b/src/test/regress/serial_schedule
@@ -67,6 +67,7 @@ test: create_index_spgist
test: create_view
test: index_including
test: index_including_gist
+test: reindex_catalog
test: create_aggregate
test: create_function_3
test: create_cast
diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql
index f6f2d7c14bb..f29b8ca826f 100644
--- a/src/test/regress/sql/create_index.sql
+++ b/src/test/regress/sql/create_index.sql
@@ -748,27 +748,6 @@ REINDEX (VERBOSE) TABLE reindex_verbose;
DROP TABLE reindex_verbose;
--
--- check that system tables can be reindexed
---
-
--- whole tables
-REINDEX TABLE pg_class; -- mapped, non-shared, critical
-REINDEX TABLE pg_index; -- non-mapped, non-shared, critical
-REINDEX TABLE pg_operator; -- non-mapped, non-shared, critical
-REINDEX TABLE pg_database; -- mapped, shared, critical
-REINDEX TABLE pg_shdescription; -- mapped, shared non-critical
-
--- Check that individual system indexes can be reindexed. That's a bit
--- different from the entire-table case because reindex_relation
--- treats e.g. pg_class special.
-REINDEX INDEX pg_class_oid_index; -- mapped, non-shared, critical
-REINDEX INDEX pg_class_relname_nsp_index; -- mapped, non-shared, non-critical
-REINDEX INDEX pg_index_indexrelid_index; -- non-mapped, non-shared, critical
-REINDEX INDEX pg_index_indrelid_index; -- non-mapped, non-shared, non-critical
-REINDEX INDEX pg_database_oid_index; -- mapped, shared, critical
-REINDEX INDEX pg_shdescription_o_c_index; -- mapped, shared, non-critical
-
---
-- REINDEX CONCURRENTLY
--
CREATE TABLE concur_reindex_tab (c1 int);
diff --git a/src/test/regress/sql/reindex_catalog.sql b/src/test/regress/sql/reindex_catalog.sql
new file mode 100644
index 00000000000..2180ee5791a
--- /dev/null
+++ b/src/test/regress/sql/reindex_catalog.sql
@@ -0,0 +1,36 @@
+--
+-- Check that system tables can be reindexed.
+--
+-- Note that this test currently has to run without parallel tests
+-- being scheduled, as currently reindex catalog tables can cause
+-- deadlocks:
+--
+-- * The lock upgrade between the ShareLock acquired for the reindex
+-- and RowExclusiveLock needed for pg_class/pg_index locks can
+-- trigger deadlocks.
+--
+-- * The uniqueness checks performed when reindexing a unique/primary
+-- key index possibly need to wait for the transaction of a
+-- about-to-deleted row in pg_class to commit. That can cause
+-- deadlocks because, in contrast to user tables, locks on catalog
+-- tables are routinely released before commit - therefore the lock
+-- held for reindexing doesn't guarantee that no running transaction
+-- performed modifications in the table underlying the index.
+
+
+-- Check reindexing of whole tables
+REINDEX TABLE pg_class; -- mapped, non-shared, critical
+REINDEX TABLE pg_index; -- non-mapped, non-shared, critical
+REINDEX TABLE pg_operator; -- non-mapped, non-shared, critical
+REINDEX TABLE pg_database; -- mapped, shared, critical
+REINDEX TABLE pg_shdescription; -- mapped, shared non-critical
+
+-- Check that individual system indexes can be reindexed. That's a bit
+-- different from the entire-table case because reindex_relation
+-- treats e.g. pg_class special.
+REINDEX INDEX pg_class_oid_index; -- mapped, non-shared, critical
+REINDEX INDEX pg_class_relname_nsp_index; -- mapped, non-shared, non-critical
+REINDEX INDEX pg_index_indexrelid_index; -- non-mapped, non-shared, critical
+REINDEX INDEX pg_index_indrelid_index; -- non-mapped, non-shared, non-critical
+REINDEX INDEX pg_database_oid_index; -- mapped, shared, critical
+REINDEX INDEX pg_shdescription_o_c_index; -- mapped, shared, non-critical