From 34984b8c95c03ad2edb2085bf00f909d0541aab7 Mon Sep 17 00:00:00 2001 From: Bridget Beh Date: Thu, 28 Sep 2023 15:39:52 +1300 Subject: [PATCH] mysql: add page for detecting and terminating long running queries This page will be linked in the user alerts to be added for long running queries are in progress and may be delaying a backup (see JIRA ticket for more details on the specific alerts). [SRE-7323] --- _toc.yml | 1 + .../howto/mysql-long-running-queries.rst | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 docs/products/mysql/howto/mysql-long-running-queries.rst diff --git a/_toc.yml b/_toc.yml index 87c29eb8ff..2a3061ccb5 100644 --- a/_toc.yml +++ b/_toc.yml @@ -955,6 +955,7 @@ entries: - file: docs/products/mysql/howto/enable-slow-queries - file: docs/products/mysql/howto/create-tables-without-primary-keys - file: docs/products/mysql/howto/create-missing-primary-keys + - file: docs/products/mysql/howto/mysql-long-running-queries - file: docs/products/mysql/howto/list-migrate-data title: Data migration entries: diff --git a/docs/products/mysql/howto/mysql-long-running-queries.rst b/docs/products/mysql/howto/mysql-long-running-queries.rst new file mode 100644 index 0000000000..8b70de00de --- /dev/null +++ b/docs/products/mysql/howto/mysql-long-running-queries.rst @@ -0,0 +1,39 @@ +Detect and terminate long-running queries +========================================= + +Aiven does not terminate any customer queries even if they run indefinitely, but long-running queries can cause issues by locking resources and therefore preventing database maintenance tasks such as backups. + +To identify and terminate such long-running queries, you can do it from either: + +* `Aiven Console `__ +* :doc:`MySQL shell <./connect-from-cli>` (``mysql``) + + +Terminate long running queries from the Aiven Console +----------------------------------------------------- + +1. Log in to the `Aiven Console `_. +2. From the **Services** page, select your Aiven for MySQL® service. +3. In your service's page, select **Current queries** from the sidebar. +4. In the **Current queries** page, you can check the query duration and select **Terminate** to stop any long-running queries. + +Detect and terminate long running queries via CLI +------------------------------------------------- + +You can :doc:`login to your service <./connect-from-cli>` using ``mysqlsh`` or ``mysql``. Once connected, you can call the following command on the ``mysql`` shell to view all running queries: + +.. code-block:: shell + + SHOW PROCESSLIST WHERE command = 'Query' AND info NOT LIKE '%PROCESSLIST%'; + +You can learn more about the ``SHOW PROCESSLIST`` command from the `official documentation `_. + +You can terminate a query manually using: + +.. code-block:: shell + + KILL QUERY pid + +where the ``pid`` is the process ID output by the `SHOW PROCESSLIST` command above. + +You can learn more about the ``KILL QUERY`` command from the `MySQL KILL documentation `_.