mirror of https://github.com/citusdata/citus.git
Merge pull request #2559 from citusdata/concurrent_concurrently
Execute CREATE INDEX CONCURRENTLY in parallel cr: @jasonmp85pull/2541/head
commit
ca83c48097
|
@ -598,7 +598,7 @@ ExecuteDistributedDDLJob(DDLJob *ddlJob)
|
||||||
|
|
||||||
PG_TRY();
|
PG_TRY();
|
||||||
{
|
{
|
||||||
ExecuteModifyTasksSequentiallyWithoutResults(ddlJob->taskList, CMD_UTILITY);
|
ExecuteModifyTasksWithoutResults(ddlJob->taskList);
|
||||||
|
|
||||||
if (shouldSyncMetadata)
|
if (shouldSyncMetadata)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1267,8 +1267,7 @@ ExecuteModifyTasksWithoutResults(List *taskList)
|
||||||
* ExecuteModifyTasksSequentiallyWithoutResults basically calls ExecuteSingleModifyTask in
|
* ExecuteModifyTasksSequentiallyWithoutResults basically calls ExecuteSingleModifyTask in
|
||||||
* a loop in order to simulate sequential execution of a list of tasks. Useful
|
* a loop in order to simulate sequential execution of a list of tasks. Useful
|
||||||
* in cases where issuing commands in parallel before waiting for results could
|
* in cases where issuing commands in parallel before waiting for results could
|
||||||
* result in deadlocks (such as CREATE INDEX CONCURRENTLY or foreign key creation to
|
* result in deadlocks (such as foreign key creation to reference tables).
|
||||||
* reference tables).
|
|
||||||
*
|
*
|
||||||
* The function returns the affectedTupleCount if applicable. Otherwise, the function
|
* The function returns the affectedTupleCount if applicable. Otherwise, the function
|
||||||
* returns 0.
|
* returns 0.
|
||||||
|
|
|
@ -43,39 +43,6 @@ WHERE nodeport = :worker_2_proxy_port;
|
||||||
localhost | 9060 | t | 0
|
localhost | 9060 | t | 0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
DROP TABLE index_test;
|
|
||||||
CREATE TABLE index_test(id int, value_1 int, value_2 int);
|
|
||||||
SELECT create_distributed_table('index_test', 'id');
|
|
||||||
create_distributed_table
|
|
||||||
--------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- kill the connection at the second create command is issued
|
|
||||||
SELECT citus.mitmproxy('conn.onQuery(query="CREATE").after(1).kill()');
|
|
||||||
mitmproxy
|
|
||||||
-----------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
CREATE INDEX CONCURRENTLY idx_index_test ON index_test(id, value_1);
|
|
||||||
ERROR: CONCURRENTLY-enabled index command failed
|
|
||||||
DETAIL: CONCURRENTLY-enabled index commands can fail partially, leaving behind an INVALID index.
|
|
||||||
HINT: Use DROP INDEX CONCURRENTLY IF EXISTS to remove the invalid index, then retry the original command.
|
|
||||||
SELECT citus.mitmproxy('conn.allow()');
|
|
||||||
mitmproxy
|
|
||||||
-----------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- verify only one index is created
|
|
||||||
SELECT * FROM run_command_on_workers($$SELECT count(*) FROM pg_indexes WHERE indexname LIKE 'idx_index_test%' $$)
|
|
||||||
WHERE nodeport = :worker_2_proxy_port;
|
|
||||||
nodename | nodeport | success | result
|
|
||||||
-----------+----------+---------+--------
|
|
||||||
localhost | 9060 | t | 1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
DROP TABLE index_test;
|
DROP TABLE index_test;
|
||||||
CREATE TABLE index_test(id int, value_1 int, value_2 int);
|
CREATE TABLE index_test(id int, value_1 int, value_2 int);
|
||||||
SELECT create_reference_table('index_test');
|
SELECT create_reference_table('index_test');
|
||||||
|
|
|
@ -27,23 +27,6 @@ WHERE nodeport = :worker_2_proxy_port;
|
||||||
DROP TABLE index_test;
|
DROP TABLE index_test;
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE index_test(id int, value_1 int, value_2 int);
|
|
||||||
SELECT create_distributed_table('index_test', 'id');
|
|
||||||
|
|
||||||
-- kill the connection at the second create command is issued
|
|
||||||
SELECT citus.mitmproxy('conn.onQuery(query="CREATE").after(1).kill()');
|
|
||||||
|
|
||||||
CREATE INDEX CONCURRENTLY idx_index_test ON index_test(id, value_1);
|
|
||||||
|
|
||||||
SELECT citus.mitmproxy('conn.allow()');
|
|
||||||
|
|
||||||
-- verify only one index is created
|
|
||||||
SELECT * FROM run_command_on_workers($$SELECT count(*) FROM pg_indexes WHERE indexname LIKE 'idx_index_test%' $$)
|
|
||||||
WHERE nodeport = :worker_2_proxy_port;
|
|
||||||
|
|
||||||
DROP TABLE index_test;
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE index_test(id int, value_1 int, value_2 int);
|
CREATE TABLE index_test(id int, value_1 int, value_2 int);
|
||||||
SELECT create_reference_table('index_test');
|
SELECT create_reference_table('index_test');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue