Add tests for concurrent index deadlock issue (#4775)

(cherry picked from commit 9728ce1167)
pull/5009/head
Onur Tirtir 2021-03-04 11:56:54 +03:00 committed by Sait Talha Nisanci
parent 61a89c69cd
commit 18ab327c6c
2 changed files with 53 additions and 0 deletions

View File

@ -49,6 +49,32 @@ BEGIN;
drop schema public cascade; drop schema public cascade;
ROLLBACK; ROLLBACK;
CREATE EXTENSION citus; CREATE EXTENSION citus;
CREATE SCHEMA test_schema;
SET search_path TO test_schema;
CREATE TABLE ref(x int, y int);
SELECT create_reference_table('ref');
create_reference_table
---------------------------------------------------------------------
(1 row)
CREATE INDEX CONCURRENTLY ref_concurrent_idx_x ON ref(x);
CREATE INDEX CONCURRENTLY ref_concurrent_idx_y ON ref(x);
SELECT substring(current_Setting('server_version'), '\d+')::int > 11 AS server_version_above_eleven
\gset
\if :server_version_above_eleven
REINDEX INDEX CONCURRENTLY ref_concurrent_idx_x;
REINDEX INDEX CONCURRENTLY ref_concurrent_idx_y;
REINDEX TABLE CONCURRENTLY ref;
REINDEX SCHEMA CONCURRENTLY test_schema;
\endif
SET search_path TO public;
\set VERBOSITY TERSE
DROP SCHEMA test_schema CASCADE;
NOTICE: drop cascades to 2 other objects
DROP EXTENSION citus CASCADE;
\set VERBOSITY DEFAULT
CREATE EXTENSION citus;
-- this function is dropped in Citus10, added here for tests -- this function is dropped in Citus10, added here for tests
CREATE OR REPLACE FUNCTION pg_catalog.master_create_worker_shards(table_name text, shard_count integer, CREATE OR REPLACE FUNCTION pg_catalog.master_create_worker_shards(table_name text, shard_count integer,
replication_factor integer DEFAULT 2) replication_factor integer DEFAULT 2)

View File

@ -42,6 +42,33 @@ BEGIN;
ROLLBACK; ROLLBACK;
CREATE EXTENSION citus; CREATE EXTENSION citus;
CREATE SCHEMA test_schema;
SET search_path TO test_schema;
CREATE TABLE ref(x int, y int);
SELECT create_reference_table('ref');
CREATE INDEX CONCURRENTLY ref_concurrent_idx_x ON ref(x);
CREATE INDEX CONCURRENTLY ref_concurrent_idx_y ON ref(x);
SELECT substring(current_Setting('server_version'), '\d+')::int > 11 AS server_version_above_eleven
\gset
\if :server_version_above_eleven
REINDEX INDEX CONCURRENTLY ref_concurrent_idx_x;
REINDEX INDEX CONCURRENTLY ref_concurrent_idx_y;
REINDEX TABLE CONCURRENTLY ref;
REINDEX SCHEMA CONCURRENTLY test_schema;
\endif
SET search_path TO public;
\set VERBOSITY TERSE
DROP SCHEMA test_schema CASCADE;
DROP EXTENSION citus CASCADE;
\set VERBOSITY DEFAULT
CREATE EXTENSION citus;
-- this function is dropped in Citus10, added here for tests -- this function is dropped in Citus10, added here for tests
CREATE OR REPLACE FUNCTION pg_catalog.master_create_worker_shards(table_name text, shard_count integer, CREATE OR REPLACE FUNCTION pg_catalog.master_create_worker_shards(table_name text, shard_count integer,
replication_factor integer DEFAULT 2) replication_factor integer DEFAULT 2)