Allow Cancellation During Distributed DDL Commands

This change allows users to interrupt long running DDL commands.
Interrupt requests are handled after each DDL command being propagated
to a shard placement, which means that generally the cancel request will
be processed right after the execution of the DDL is finished in the
current placement.
pull/686/head
Eren Başak 2016-07-28 16:16:21 +03:00
parent 1ee3d091da
commit 40f8149320
1 changed files with 2 additions and 12 deletions

View File

@ -676,7 +676,6 @@ static Node *
ProcessAlterObjectSchemaStmt(AlterObjectSchemaStmt *alterObjectSchemaStmt, ProcessAlterObjectSchemaStmt(AlterObjectSchemaStmt *alterObjectSchemaStmt,
const char *alterObjectSchemaCommand, bool isTopLevel) const char *alterObjectSchemaCommand, bool isTopLevel)
{ {
Oid relationId = InvalidOid; Oid relationId = InvalidOid;
bool noWait = false; bool noWait = false;
@ -1071,9 +1070,6 @@ ExecuteDistributedDDLCommand(Oid relationId, const char *ddlCommandString,
"to execute DDL commands on distributed tables."))); "to execute DDL commands on distributed tables.")));
} }
/* make sure we don't process cancel signals */
HOLD_INTERRUPTS();
executionOK = ExecuteCommandOnWorkerShards(relationId, ddlCommandString); executionOK = ExecuteCommandOnWorkerShards(relationId, ddlCommandString);
/* if command could not be executed on any finalized shard placement, error out */ /* if command could not be executed on any finalized shard placement, error out */
@ -1081,14 +1077,6 @@ ExecuteDistributedDDLCommand(Oid relationId, const char *ddlCommandString,
{ {
ereport(ERROR, (errmsg("could not execute DDL command on worker node shards"))); ereport(ERROR, (errmsg("could not execute DDL command on worker node shards")));
} }
if (QueryCancelPending)
{
ereport(WARNING, (errmsg("cancel requests are ignored during DDL commands")));
QueryCancelPending = false;
}
RESUME_INTERRUPTS();
} }
@ -1226,6 +1214,8 @@ ExecuteCommandOnShardPlacements(StringInfo applyCommand, uint64 shardId,
PQclear(result); PQclear(result);
transactionConnection->transactionState = TRANSACTION_STATE_OPEN; transactionConnection->transactionState = TRANSACTION_STATE_OPEN;
CHECK_FOR_INTERRUPTS();
} }
} }