Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions docs/_docs/tools/control-script.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,65 @@ For example, to cancel the transactions that have been running for more than 100
control.sh --tx --min-duration 100 --kill
----

== Mass Cancellation of Queries

The control script allows you to mass cancel SQL queries, scan queries, index queries and continuous queries that match specific criteria.

The syntax for the mass cancellation command is as follows:

[tabs]
--
tab:Unix[]
[source,shell,subs="verbatim,quotes"]
----
control.sh --kill all <target> [--node-id <nodeId>] [--min-duration <seconds>]
----
tab:Windows[]
[source,shell,subs="verbatim,quotes"]
----
control.bat --kill all <target> [--node-id <nodeId>] [--min-duration <seconds>]
----
--

The following target types are supported:

[cols="1,3",opts="header"]
|===
|Target | Description
|`sql`| SQL queries
|`scan`| Scan queries
|`index`| Index queries
|`continuous`| Continuous queries
|===

Parameters:

[cols="2,5",opts="header"]
|===
|Parameter | Description
|--nodeId <nodeId>| Optional. UUID of the originator node to filter targets.
|--min-duration <seconds>| Optional. Minimum duration in seconds. Only objects that have been running longer than the specified value will be cancelled.
|===

Example commands:

[source, shell]
----
# Cancel all SQL queries that have been running for more than 60 seconds
control.sh --kill all sql --min-duration 60

# Cancel scan queries that have been running for more than 30 seconds on a specific node
control.sh --kill all scan --nodeId <uuid> --min-duration 30

# Cancel index queries on a specific node
control.sh --kill all index --nodeId <uuid>

# Cancel continuous queries
control.sh --kill all continuous
----

To cancel specific individual objects (without mass filtering) see link:sql-reference/operational-commands[Operational Commands] section.

== Contention Detection in Transactions

The `contention` command detects when multiple transactions are in contention to create a lock for the same key. The command is useful if you have long-running or hanging transactions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
import org.apache.ignite.internal.management.encryption.EncryptionCommand;
import org.apache.ignite.internal.management.event.EventCommand;
import org.apache.ignite.internal.management.io.IoTestCommand;
import org.apache.ignite.internal.management.kill.KillAllCommand;
import org.apache.ignite.internal.management.kill.KillAllCommandArg;
import org.apache.ignite.internal.management.kill.KillCommand;
import org.apache.ignite.internal.management.meta.MetaCommand;
import org.apache.ignite.internal.management.meta.MetaRemoveCommand;
Expand Down Expand Up @@ -479,6 +481,13 @@ else if (cmd.getClass() == CacheClearCommand.class) {

arg = (A)a;
}
else if (cmd.getClass() == KillAllCommand.class) {
KillAllCommandArg a = new KillAllCommandArg();

a.target(KillAllCommandArg.TargetType.SQL);

arg = (A)a;
}
else
arg = cmd.argClass().newInstance();

Expand Down Expand Up @@ -524,6 +533,8 @@ else if (cmd.getClass() == MetaUpdateCommand.class)
return;
else if (cmd.getClass() == MetaRemoveCommand.class)
cmdText = F.concat(cmdText, "--typeId", "1");
else if (cmd.getClass() == KillAllCommand.class)
cmdText = F.concat(cmdText, "SQL");

args = parseArgs(asList(cmdText));

Expand Down Expand Up @@ -695,6 +706,14 @@ public void testKillArguments() {

assertParseArgsThrows("String representation of \"java.util.UUID\" is exepected", IllegalArgumentException.class,
"--kill", "continuous", UUID.randomUUID().toString(), "not_a_uuid");

// Kill all command format errors.
assertParseArgsThrows("Argument target required.", "--kill", "all");
assertParseArgsThrows("Can't parse value 'unknown'", "--kill", "all", "unknown");
assertParseArgsThrows("Argument is invalid: --min-duration", "--kill", "all", "sql", "--min-duration", "-1");
assertParseArgsThrows("Argument is invalid: --min-duration", "--kill", "all", "sql", "--min-duration", "0");
assertParseArgsThrows("Argument is invalid: --minDuration is not supported for CONTINUOUS queries",
"--kill", "all", "continuous", "--min-duration", "60");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.ignite.util.GridCommandHandlerWithSslFactoryTest;
import org.apache.ignite.util.GridCommandHandlerWithSslTest;
import org.apache.ignite.util.GridPersistenceCommandsTest;
import org.apache.ignite.util.KillAllCommandsControlShTest;
import org.apache.ignite.util.KillCommandsControlShTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
Expand Down Expand Up @@ -76,6 +77,7 @@
GridCommandHandlerLegacyClientTest.class,

KillCommandsControlShTest.class,
KillAllCommandsControlShTest.class,

BaselineEventsLocalTest.class,
BaselineEventsRemoteTest.class,
Expand Down
Loading
Loading