社区版OBProxy无法kill会话连接

问题描述

按照对应3.1.3社区版的OBProxy官方文档描述的使用kill proxysession id的方式杀掉普通会话报错 ID不存在.

环境信息

root@127.0.0.1[oceanbase]> \s
--------------
obclient  Ver 15.1 Distrib 10.4.18-MariaDB, for Linux (x86_64) using readline 5.1

Connection id:		1048601
Current database:	oceanbase
Current user:		root@127.0.0.1
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server:			MySQL
Server version:		5.6.25 OceanBase 3.1.3 (r10100032022041510-a09d3134c10665f03fd56d7f8bdd413b2b771977) (Built Apr 15 2022 02:16:22)
Protocol version:	10
Connection:		127.0.0.1 via TCP/IP
Server characterset:	utf8mb4
Db     characterset:	utf8mb4
Client characterset:	utf8mb4
Conn.  characterset:	utf8mb4
TCP port:		2883
Active			--------------

## OBProxy 版本信息
root@127.0.0.1[oceanbase]> show proxyinfo binary\G
*************************** 1. row ***************************
name: binary info
info: ObProxy-OceanBase 3.2.0-1
version:RELEASE_UNKNOWN
MD5:
REVISION:58-local-b91a4006ba52e107d1a3edb03a50f3d14ef63cd8
BUILD_TIME:Nov  3 2021 06:51:33
BUILD_FLAGS:-g -O2 -D_OB_VERSION=1000 -D_NO_EXCEPTION -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -D__USE_LARGEFILE64 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wextra -Wunused-parameter -Wformat -Wconversion -Wno-deprecated -Wno-invalid-offsetof -finline-functions -fno-strict-aliasing -mtune=core2 -Wno-psabi -Wno-sign-compare -DGCC_52 -DSUPPORT_SSE4_2 -DHAVE_SCHED_GETCPU -DHAVE_REALTIME_COARSE -DOB_HAVE_EVENTFD -DHAVE_FALLOCATE -Werror
1 row in set (0.004 sec)

复现步骤

## 查看当前的连接, OBProxy的查看方式
root@127.0.0.1[oceanbase]> show proxysession;
+--------------+---------+----------+----------+------+---------------------+-----------+-------------+-------------------+-------------------+------+------+
| proxy_sessid | Id      | Cluster  | Tenant   | User | Host                | db        | trans_count | svr_session_count | state             | tid  | pid  |
+--------------+---------+----------+----------+------+---------------------+-----------+-------------+-------------------+-------------------+------+------+
|           97 | 1048601 | zhenxing | sys      | root | 127.0.0.1:25374     | oceanbase |           0 |                 1 | MCS_ACTIVE_READER | 3767 | 3754 |
|           92 |      55 | zhenxing | zhenxing | root | 10.186.61.159:64190 | NULL      |           0 |                 1 | MCS_ACTIVE_READER | 3754 | 3754 |
+--------------+---------+----------+----------+------+---------------------+-----------+-------------+-------------------+-------------------+------+------+
2 rows in set (0.066 sec)

## 查看当前的连接, 后端OBserver的连接
root@127.0.0.1[oceanbase]> show processlist;
+---------+----------+------+---------------------+-----------+-------------+-------------------+-------------------+------+------+
| Id      | Tenant   | User | Host                | db        | trans_count | svr_session_count | state             | tid  | pid  |
+---------+----------+------+---------------------+-----------+-------------+-------------------+-------------------+------+------+
| 1048601 | sys      | root | 127.0.0.1:25374     | oceanbase |           0 |                 1 | MCS_ACTIVE_READER | 3767 | 3754 |
|      55 | zhenxing | root | 10.186.61.159:64190 | NULL      |           0 |                 1 | MCS_ACTIVE_READER | 3754 | 3754 |
+---------+----------+------+---------------------+-----------+-------------+-------------------+-------------------+------+------+
2 rows in set (0.024 sec)

## 按照官方文档语法, 杀掉ID为55的连接触发报错,
root@127.0.0.1[oceanbase]> kill proxysession 55;
ERROR 1094 (HY000): Unknown thread id: 55

## 按照官方文档语法, 杀掉ID为1048601的连接,可正常执行(备注: 1048601就是本会话的连接ID)
root@127.0.0.1[oceanbase]> kill proxysession 1048601;
ERROR 1317 (70100): Query execution was interrupted

## 执行命令可以看到该连接已断开
root@127.0.0.1[oceanbase]> \s
ERROR 2013 (HY000): Lost connection to MySQL server during query

官方文档链接

请再尝试show processlist; 看看55是否已经断开。

没有的,反复验证了,连接一直是活着的

仔细看看使用手册?

SHOW PROXYSESSION;的结果,使用KILL PROXYSESSION id,这个id是proxy_sessid,不是显示的id.

你用错了id。你用的55那个id应该是用kill 55 可以达到你要的效果。

kill proxysession 92才是你语法的正确id.

不是,手册链接我已经贴出来了,并且手册上的操作和我一模一样,ID肯定是没指定错的

从验证结果来看去kill普通租户的session确实就是会报错.稳定复现

kill proxysession id的这个ID不是proxy_sessid

show proxysession输出结果中对id的定义,id=cs_id

kill proxysession id中对id的定义,这里的id就是cs_id,connection_id()函数获取的id

麻烦提供一下如何登录后执行的 kill proxysession xxx

1、使用root@proxysys 登录
2、show proxysession; 找到需要kill 的id ,比如100
3、show proxysession attribute 100; 找到 server_sessid 字段,比如200
4、kill proxysession 200;

另外一种方法:
1、使用root@sys 登录
show full processlist; 找到需要kill 的 ID(第一个字段),比如666。
2、使用root@proxysys 登录
kill proxysession 666;(第一步获取的ID)