KILL

    • KILL语法在非线程池模式和线程池模式下均有效。
    • 一般结合SHOW PROCESSSLIST的查询结果Id字段使用。
    • 也可以结合select sessionid from pg_stat_activity where (过滤条件) 使用
    • CONNECTION

    • QUERY

    • processlist_id

    1. openGauss=# show processlist;
    2. Id | Pid | QueryId | UniqueSqlId | User | Host | db | Command |
    3. BackendStart | XactStart | Time | State | Info
    4. -----------------+-----------------+-------------------+-------------+-----------+------+----------+------------------------+---
    5. ----------------------------+-------------------------------+--------+--------+----------------------------------------
    6. 139653370304256 | 139653370304256 | 0 | 0 | opengauss | | postgres | ApplyLauncher | 20
    7. 22-06-21 16:46:19.656076+08 | | | |
    8. 139653319255808 | 139653319255808 | 0 | 0 | opengauss | | postgres | Asp | 20
    9. 22-06-21 16:46:19.728521+08 | | 1 | active |
    10. 139653336483584 | 139653336483584 | 0 | 0 | opengauss | | postgres | PercentileJob | 20
    11. 22-06-21 16:46:19.728527+08 | | 8 | active |
    12. 139653302175488 | 139653302175488 | 0 | 0 | opengauss | | postgres | statement flush thread | 20
    13. 22-06-21 16:46:19.728558+08 | | 508507 | idle |
    14. 139653198239488 | 139653198239488 | 0 | 0 | opengauss | | postgres | WorkloadMonitor | 20
    15. 22-06-21 16:46:19.750133+08 | | | |
    16. 139653181298432 | 139653181298432 | 0 | 0 | opengauss | | postgres | WLMArbiter | 20
    17. 22-06-21 16:46:19.750976+08 | | | |
    18. 139653215110912 | 139653215110912 | 0 | 0 | opengauss | | postgres | workload | 20
    19. 22-06-21 16:46:19.754504+08 | 2022-06-21 16:46:19.769585+08 | 508507 | active | WLM fetch collect info from data nodes
    20. 139653421840128 | 139653421840128 | 0 | 0 | opengauss | | postgres | JobScheduler | 20
    21. 22-06-27 10:00:54.754007+08 | | 0 | active |
    22. 139653044328192 | 139653044328192 | 48976645947655327 | 1772643515 | opengauss | -1 | dolphin | gsql | 20
    23. 22-06-27 14:00:53.163338+08 | 2022-06-27 14:01:26.794658+08 | 0 | active | show processlist;
    24. 139653027546880 | 139653027546880 | 48976645947655326 | 1775585557 | opengauss | -1 | postgres | gsql | 20
    25. 22-06-27 14:01:03.969962+08 | 2022-06-27 14:01:19.967521+08 | 7 | active | select pg_sleep(100);
    26. --终止139653027546880连接执行的SQL语句
    27. openGauss=# kill query 139653027546880;
    28. result
    29. --------
    30. t
    31. (1 row)
    32. --查看processlist139653027546880连接状态,已经变为idle
    33. openGauss=# show processlist;
    34. Id | Pid | QueryId | UniqueSqlId | User | Host | db | Command |
    35. BackendStart | XactStart | Time | State | Info
    36. -----------------+-----------------+-------------------+-------------+-----------+------+----------+------------------------+---
    37. ----------------------------+-------------------------------+--------+--------+----------------------------------------
    38. 139653370304256 | 139653370304256 | 0 | 0 | opengauss | | postgres | ApplyLauncher | 20
    39. 22-06-21 16:46:19.656076+08 | | | |
    40. 139653319255808 | 139653319255808 | 0 | 0 | opengauss | | postgres | Asp | 20
    41. 22-06-21 16:46:19.728521+08 | | 0 | active |
    42. 139653336483584 | 139653336483584 | 0 | 0 | opengauss | | postgres | PercentileJob | 20
    43. 22-06-21 16:46:19.728527+08 | | 5 | active |
    44. 139653302175488 | 139653302175488 | 0 | 0 | opengauss | | postgres | statement flush thread | 20
    45. 22-06-21 16:46:19.728558+08 | | 508573 | idle |
    46. 139653198239488 | 139653198239488 | 0 | 0 | opengauss | | postgres | WorkloadMonitor | 20
    47. 22-06-21 16:46:19.750133+08 | | | |
    48. 139653181298432 | 139653181298432 | 0 | 0 | opengauss | | postgres | WLMArbiter | 20
    49. 22-06-21 16:46:19.750976+08 | | | |
    50. 139653215110912 | 139653215110912 | 0 | 0 | opengauss | | postgres | workload | 20
    51. 22-06-21 16:46:19.754504+08 | 2022-06-21 16:46:19.769585+08 | 508573 | active | WLM fetch collect info from data nodes
    52. 139653421840128 | 139653421840128 | 0 | 0 | opengauss | | postgres | JobScheduler | 20
    53. 22-06-27 10:00:54.754007+08 | | 1 | active |
    54. 139653044328192 | 139653044328192 | 48976645947655329 | 1772643515 | opengauss | -1 | dolphin | gsql | 20
    55. 22-06-27 14:00:53.163338+08 | 2022-06-27 14:02:33.180256+08 | 0 | active | show processlist;
    56. 139653027546880 | 139653027546880 | 0 | 0 | opengauss | -1 | postgres | gsql | 20
    57. 22-06-27 14:01:03.969962+08 | | 11 | idle | select pg_sleep(100);
    58. (10 rows)
    59. --终止139653027546880连接
    60. result
    61. --------
    62. t
    63. --或
    64. openGauss=# kill connection 139653027546880;
    65. result
    66. --------
    67. t
    68. (1 row)
    69. --查看processlist中已经不存在该连接
    70. openGauss=# show processlist;
    71. Id | Pid | QueryId | UniqueSqlId | User | Host | db | Command |
    72. BackendStart | XactStart | Time | State | Info
    73. -----------------+-----------------+-------------------+-------------+-----------+------+----------+------------------------+---
    74. ----------------------------+-------------------------------+--------+--------+----------------------------------------
    75. 139653370304256 | 139653370304256 | 0 | 0 | opengauss | | postgres | ApplyLauncher | 20
    76. 22-06-21 16:46:19.656076+08 | | | |
    77. 139653319255808 | 139653319255808 | 0 | 0 | opengauss | | postgres | Asp | 20
    78. 22-06-21 16:46:19.728521+08 | | 1 | active |
    79. 139653336483584 | 139653336483584 | 0 | 0 | opengauss | | postgres | PercentileJob | 20
    80. 22-06-21 16:46:19.728527+08 | | 7 | active |
    81. 139653302175488 | 139653302175488 | 0 | 0 | opengauss | | postgres | statement flush thread | 20
    82. 22-06-21 16:46:19.728558+08 | | 508696 | idle |
    83. 139653198239488 | 139653198239488 | 0 | 0 | opengauss | | postgres | WorkloadMonitor | 20
    84. 22-06-21 16:46:19.750133+08 | | | |
    85. 139653181298432 | 139653181298432 | 0 | 0 | opengauss | | postgres | WLMArbiter | 20
    86. 22-06-21 16:46:19.750976+08 | | | |
    87. 139653215110912 | 139653215110912 | 0 | 0 | opengauss | | postgres | workload | 20
    88. 22-06-21 16:46:19.754504+08 | 2022-06-21 16:46:19.769585+08 | 508696 | active | WLM fetch collect info from data nodes
    89. 139653421840128 | 139653421840128 | 0 | 0 | opengauss | | postgres | JobScheduler | 20
    90. 22-06-27 10:00:54.754007+08 | | 1 | active |
    91. 139653044328192 | 139653044328192 | 48976645947655331 | 1772643515 | opengauss | -1 | dolphin | gsql | 20
    92. 22-06-27 14:00:53.163338+08 | 2022-06-27 14:04:35.418518+08 | 0 | active | show processlist;