Add tests for concurrent index deadlock issue (#4775)

pull/4765/head^2
Onur Tirtir 2021-03-04 11:56:54 +03:00 committed by GitHub
parent d7880df4ab
commit 9728ce1167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 0 deletions

View File

@ -49,6 +49,32 @@ BEGIN;
drop schema public cascade;
ROLLBACK;
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
CREATE OR REPLACE FUNCTION pg_catalog.master_create_worker_shards(table_name text, shard_count integer,
replication_factor integer DEFAULT 2)

View File

@ -42,6 +42,33 @@ BEGIN;
ROLLBACK;
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
CREATE OR REPLACE FUNCTION pg_catalog.master_create_worker_shards(table_name text, shard_count integer,
replication_factor integer DEFAULT 2)