描述

    对于kill query proceselist_id语句:

    • 可以kill query掉指定proceselist_id的session
    • 普通用户默认只能kill query当前用户下所有session, 其他租户下session对其不可见,相同租户下其他用户的session的kill query与否根据其当前租户权限确定.
    • observer的SYS租户可kill query本租户内任意一个session
    • 以下三种情况时将不支持kill query,返回 ERROR 1235 (0A000): Not supported feature or function

    • 处于事务中时,例如,begin。

    • 当前sql依赖上一条sql执行结果时,如select found_rows()/ select row_count()/ show errors/ show warnings等。
    • 已经指定下一条transaction特性时,如set transaction xxx

    示例

    1. OceanBase (admin@oceanbase)> show processlist;
    2. +-------+--------+-------+--------------------+-----------+-------------+-------------------+-------------------+------+------+
    3. | Id | Tenant | User | Host | db | trans_count | svr_session_count | state | tid | pid |
    4. +-------+--------+-------+--------------------+-----------+-------------+-------------------+-------------------+------+------+
    5. | 10017 | sys | admin | 10.125.111.4:34628 | oceanbase | 67 | 1 | MCS_ACTIVE_READER | 2891 | 2891 |
    6. +-------+--------+-------+--------------------+-----------+-------------+-------------------+-------------------+------+------+
    7. 1 row in set (0.01 sec)
    8. OceanBase (admin@oceanbase)> select * from __all_core_table join ob_all_proxy_config;
    9. ^Ccatch sig: 2
    10. Ctrl-C -- sending "KILL QUERY 10017" to server ...
    11. Ctrl-C -- query aborted.
    12. ERROR 1317 (70100): Query execution was interrupted
    13. OceanBase (admin@oceanbase)> show processlist;
    14. +-------+--------+-------+--------------------+-----------+-------------+-------------------+-------------------+------+------+
    15. | Id | Tenant | User | Host | db | trans_count | svr_session_count | state | tid | pid |
    16. +-------+--------+-------+--------------------+-----------+-------------+-------------------+-------------------+------+------+
    17. | 10017 | sys | admin | 10.125.111.4:34628 | oceanbase | 69 | 1 | MCS_ACTIVE_READER | 2891 | 2891 |
    18. +-------+--------+-------+--------------------+-----------+-------------+-------------------+-------------------+------+------+
    19. 1 row in set (0.01 sec)
    20. OceanBase (sqluser01@(none))> show processlist;
    21. +-------+--------+-----------+----------------------+------+-------------+-------------------+-------------------+------+------+
    22. | Id | Tenant | User | Host | db | trans_count | svr_session_count | state | tid | pid |
    23. +-------+--------+-----------+----------------------+------+-------------+-------------------+-------------------+------+------+
    24. | 10020 | sys | sqluser01 | 100.69.197.111:56934 | NULL | 5 | 1 | MCS_ACTIVE_READER | 2900 | 2891 |
    25. +-------+--------+-----------+----------------------+------+-------------+-------------------+-------------------+------+------+
    26. 1 row in set (0.01 sec)
    27. OceanBase (sqluser01@(none))> kill query 10017;
    28. ERROR 1227 (42501): Access denied; you need (at least one of) the SUPER privilege(s) for this operation
    1. OceanBase (admin@oceanbase)> begin;
    2. Query OK, 0 rows affected (0.00 sec)
    3. OceanBase (admin@oceanbase)> show tables;
    4. +------------------------------------+
    5. | Tables_in_oceanbase |
    6. +------------------------------------+
    7. | ob_all_proxy |
    8. | ob_all_proxy_config |
    9. | ob_all_proxy_kv_table |
    10. | ob_all_proxy_stat |
    11. | ob_all_proxy_vip_tenant_table |
    12. +------------------------------------+
    13. 5 rows in set (0.01 sec)
    14. OceanBase (admin@oceanbase)> kill query 10021;
    15. ERROR 1235 (0A000): Not supported feature or function
    16. OceanBase (admin@oceanbase)> commit;
    17. Query OK, 0 rows affected (0.01 sec)
    18. OceanBase (admin@oceanbase)> set transaction read only;
    19. Query OK, 0 rows affected (0.00 sec)
    20. OceanBase (admin@oceanbase)> kill query 10021;
    21. ERROR 1235 (0A000): Not supported feature or function