OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database Proxy

V4.2.0Community Edition

  • What is ODP?
  • Installation and deployment
    • Deploy ODP by using OBD
    • Deploy ODP by using OCP
    • Deploy ODP by using the CLI
    • Deployment modes
  • Basic operations
  • Configuration parameter
    • Parameter description
    • Dynamically modifiable parameters
    • Parameters that are not dynamically modifiable
    • Internal and inherited parameters
    • In-memory parameters
  • Connection management
    • Principles
    • Session status synchronization
    • Client session
    • Server session
  • Data routing
    • Factors affecting data routing
    • Routing strategies
    • ODP routing
    • Intra-tenant routing
    • Read/Write separation
    • Follower latency threshold
  • High availability mechanism
    • Overview
    • High availability of ODP services
    • High availability of OceanBase Database
    • High availability testing
  • Security and protocols
  • Operation and maintenance
    • Troubleshooting
      • Troubleshooting logic
      • Monitoring logs
    • Performance analysis
    • Show Trace

Download PDF

What is ODP? Deploy ODP by using OBD Deploy ODP by using OCP Deploy ODP by using the CLI Deployment modes Basic operations Parameter description Dynamically modifiable parameters Parameters that are not dynamically modifiable Internal and inherited parameters In-memory parameters Principles Session status synchronization Client session Server session Factors affecting data routing Routing strategies ODP routing Intra-tenant routing Read/Write separation Follower latency threshold Overview High availability of ODP services High availability of OceanBase Database High availability testing Security and protocols Troubleshooting logic Monitoring logs Performance analysis Show Trace
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. OceanBase Database Proxy
  3. V4.2.0
iconOceanBase Database Proxy
V 4.2.0Community Edition
  • V 4.3.6
  • V 4.3.4
  • V 4.3.3
  • V 4.3.2
  • V 4.3.1
  • V 4.3.0
  • V 4.2.3
  • V 4.2.2
  • V 4.2.0 and earlier
Community Edition
  • V 4.2.0
  • V 4.1.0
  • V 4.0.0
  • V 3.1.0

Client session

Last Updated:2023-10-10 02:43:33  Updated
share
What is on this page
View client sessions
View the details of a client session
View the variables of a client session
Terminate a client session
Terminate a session by specifying the client session ID
Terminate a session by specifying the connection ID

folded

share

This topic describes several general operations performed on a client session, which is established between a client and OceanBase Database Proxy (ODP).

View client sessions

You can use the SHOW PROXYSESSION statement to view the client sessions of all tenants in ODP. For example:

obclient> show proxysession;
+---------------------+------+---------+--------+------+-----------------+------+-------------+-------------------+-------------------+--------+--------+-----------+
| proxy_sessid        | Id   | Cluster | Tenant | User | Host            | db   | trans_count | svr_session_count | state             | tid    | pid    | using_ssl |
+---------------------+------+---------+--------+------+-----------------+------+-------------+-------------------+-------------------+--------+--------+-----------+
| 7230691421644980673 |   88 |  ob1.cc | sys    | root | 127.0.0.1:49999 | NULL |           0 |                 1 | MCS_ACTIVE_READER | 120685 | 120685 |         0 |
+---------------------+------+---------+--------+------+-----------------+------+-------------+-------------------+-------------------+--------+--------+-----------+
1 row in set

The following table describes the fields in the returned result.

Field Description
proxy_sessid The ID of the client session allocated by OceanBase Database.
Id The ID of the client session allocated by ODP. It is equivalent to cs_id mentioned later.
Cluster The name of the OceanBase cluster to which the client session belongs.
Tenant The tenant account for connecting to the OceanBase cluster.
User The username for connecting to the OceanBase cluster.
Host The IP address and port number of the client.
db The database in which the statement is executed.
trans_count The number of transactions completed in the client session.
svr_session_count The total number of sessions held between ODP and OceanBase Database.
state The state of the client session. Valid values:
  • MCS_INIT: being initialized
  • MCS_ACTIVE_READER: active
  • MCS_KEEP_ALIVE: alive
  • MCS_HALF_CLOSE: half-closed
  • MCS_CLOSED: closed
tid The thread ID.
pid The process ID.
using_ssl Indicates whether the client session uses the Secure Sockets Layer (SSL) protocol for transmission.

View the details of a client session

You can use the SHOW PROXYSESSION ATTRIBUTE statement to query the details of a client session, including related server sessions of this client session. SQL syntax:

SHOW PROXYSESSION ATTRIBUTE [id [like 'xxx']]

Parameters:

  • If the id parameter is not specified, the details of the current session are returned (supported as of ODP V1.1.0). Fuzzy search is supported for retrieving the value of a specified attribute name in the current session (supported as of ODP V1.1.2).

  • If the id parameter is specified, fuzzy search is supported for retrieving the value of a specified attribute name (supported as of ODP V1.1.0).

  • id can be replaced with cs_id or CONNECTION_ID, and the returned result will still be the same.

  • cs_id indicates the ID of a client session in ODP. CONNECTION_ID indicates the ID of a client session in OceanBase Database. For more information about CONNECTION_ID, see CONNECTION_ID.

  • The like clause supports fuzzy search. Supported wildcard characters are the percent sign (%) and the underscore (_).

Example:

obclient> SHOW PROXYSESSION;
+--------------------+------+---------+--------+------+-----------------+------+-------------+-------------------+-------------------+---------+---------+
| proxy_sessid       | Id   | Cluster | Tenant | User | Host            | db   | trans_count | svr_session_count | state             | tid     | pid     |
+--------------------+------+---------+--------+------+-----------------+------+-------------+-------------------+-------------------+---------+---------+
| 756006681247547396 |    2 |  ob1.cc | sys    | root | 127.0.0.1:22540 | NULL |           0 |                 1 | MCS_ACTIVE_READER | 2230520 | 2230520 |
+--------------------+------+---------+--------+------+-----------------+------+-------------+-------------------+-------------------+---------+---------+
1 row in set

obclient> SHOW PROXYSESSION ATTRIBUTE;
+----------------------------------+----------------------+----------------+
| attribute_name                   | value                | info           |
+----------------------------------+----------------------+----------------+
| proxy_sessid                     | 756006681247547396   | cs common      |
| cs_id                            | 2                    | cs common      |
| cluster                          | ob1.cc               | cs common      |
| tenant                           | sys                  | cs common      |
| user                             | root                 | cs common      |
| host_ip                          | 127.0.0.1            | cs common      |
| host_port                        | 22540                | cs common      |
| db                               | NULL                 | cs common      |
| total_trans_cnt                  | 0                    | cs common      |
| svr_session_cnt                  | 1                    | cs common      |
| active                           | true                 | cs common      |
| read_state                       | MCS_ACTIVE_READER    | cs common      |
| tid                              | 2230520              | cs common      |
| pid                              | 2230520              | cs common      |
| idc_name                         |                      | cs common      |
| modified_time                    | 1469435190244371115  | cs stat        |
| reported_time                    | 1469435190244371115  | cs stat        |
| hot_sys_var_version              | 0                    | cs var version |
| sys_var_version                  | 0                    | cs var version |
| user_var_version                 | 0                    | cs var version |
| last_insert_id_version           | 0                    | cs var version |
| db_name_version                  | 0                    | cs var version |
| server_ip                        | xx.xx.xx.xx          | last used ss   |
| server_port                      | 13203                | last used ss   |
| server_sessid                    | 2147549201           | last used ss   |
| ss_id                            | 4                    | last used ss   |
| state                            | MSS_KA_CLIENT_SLAVE  | last used ss   |
| transact_count                   | 2                    | last used ss   |
| server_trans_stat                | 0                    | last used ss   |
| hot_sys_var_version              | 0                    | last used ss   |
| sys_var_version                  | 0                    | last used ss   |
| user_var_version                 | 0                    | last used ss   |
| last_insert_id_version           | 0                    | last used ss   |
| db_name_version                  | 0                    | last used ss   |
| is_checksum_supported            | 1                    | last used ss   |
| is_safe_read_weak_supported      | 0                    | last used ss   |
| is_checksum_switch_supported     | 1                    | last used ss   |
| checksum_switch                  | 1                    | last used ss   |
| enable_extra_ok_packet_for_stats | 1                    | last used ss   |
+----------------------------------+----------------------+----------------+
39 rows in set

obclient> SHOW PROXYSESSION ATTRIBUTE 2 like '%id%';
+------------------------+--------------------+----------------+
| attribute_name         | value              | info           |
+------------------------+--------------------+----------------+
| proxy_sessid           | 756006681247547396 | cs common      |
| cs_id                  | 2                  | cs common      |
| tid                    | 2230520            | cs common      |
| pid                    | 2230520            | cs common      |
| last_insert_id_version | 0                  | cs var version |
| server_sessid          | 2147549201         | last used ss   |
| ss_id                  | 4                  | last used ss   |
| last_insert_id_version | 0                  | last used ss   |
+------------------------+--------------------+----------------+
8 rows in set

obclient> SHOW PROXYSESSION ATTRIBUTE 2147549201 like '%id%';
+------------------------+--------------------+----------------+
| attribute_name         | value              | info           |
+------------------------+--------------------+----------------+
| proxy_sessid           | 756006681247547396 | cs common      |
| cs_id                  | 2                  | cs common      |
| tid                    | 2230520            | cs common      |
| pid                    | 2230520            | cs common      |
| last_insert_id_version | 0                  | cs var version |
| server_sessid          | 2147549201         | last used ss   |
| ss_id                  | 4                  | last used ss   |
| last_insert_id_version | 0                  | last used ss   |
+------------------------+--------------------+----------------+
8 rows in set

The following table describes the fields in the returned result.

Field Description
attribute_name The attribute name.
value The attribute value.
info The basic information.

The following table describes the general attributes.

Attribute Description
proxy_sessid The ID of the client session allocated by OceanBase Database.
cs_id The ID of the client session allocated by ODP. It is equivalent to the Id parameter mentioned earlier.
cluster The name of the OceanBase cluster to which the client session belongs.
tenant The tenant account for connecting to the OceanBase cluster.
user The username for connecting to the OceanBase cluster.
host_ip The IP address of the client.
host_port The port number of the client.
db The database in which the statement is executed.
total_trans_cnt The total number of transactions transmitted by ODP.
svr_session_cnt The total number of sessions held between ODP and OceanBase Database.
active Indicates whether the session is active.
read_state The state of the client session. Valid values:
  • MCS_INIT: being initialized
  • MCS_ACTIVE_READER: active
  • MCS_KEEP_ALIVE: alive
  • MCS_HALF_CLOSE: half-closed
  • MCS_CLOSED: closed
tid The thread ID.
pid The process ID.
modified_time The time when the session was modified.
reported_time The time when the session was reported.
hot_sys_var_version The version of the system variable that is updated in real time.
sys_var_version The system variable version.
user_var_version The user variable version.
last_insert_id_version The last inserted ID version.
db_name_version The database name version.
server_ip The IP address of the OBServer node.
server_port The port number of the OBServer node.
server_sessid The session ID of the OBServer node.
ss_id The ID of the server session in ODP.

View the variables of a client session

Session variables are classified into system variables and user variables. You can use the SHOW PROXYSESSION VARIABLES [all] id [like 'xx'] statement to view the variables of a client session.

  • If the all parameter is omitted, the local session variables of the specified client session, including modified system and user variables, are returned.

  • If the all parameter is not omitted, all session variables of the specified client session, including all system and user variables, are returned.

Parameters:

  • id can be replaced with cs_id or CONNECTION_ID, and the returned result will still be the same.

  • cs_id indicates the ID of a client session in ODP. CONNECTION_ID indicates the ID of a client session in OceanBase Database. For more information about CONNECTION_ID, see CONNECTION_ID.

  • The like clause supports fuzzy search. Supported wildcard characters are the percent sign (%) and the underscore (_).

Example:

  1. Query session variables by cs_id.

    obclient> SHOW PROXYSESSION VARIABLES 3;
    +-----------------------------------+------------------+-----------------+--------------------+--------------------------------------------+
    | variable_name                     | value            | info            | modified_type      | sys_variable_flag                          |
    +-----------------------------------+------------------+-----------------+--------------------+--------------------------------------------+
    | ob_proxy_global_variables_version | 1461742173142100 | changed sys var | cold modified vars |  && invisible && session_scope && readonly |
    | ob_proxy_user_privilege           | 65534            | changed sys var | cold modified vars |  && invisible && session_scope && readonly |
    | ob_capability_flag                | 654159           | changed sys var | cold modified vars |  && invisible && session_scope && readonly |
    | ob_enable_transmission_checksum   | 1                | changed sys var | cold modified vars |  && global_scope && session_scope          |
    | _min_cluster_version              | '4.1.0.1'        | user var        | cold modified vars |                                            |
    +-----------------------------------+------------------+-----------------+--------------------+--------------------------------------------+
    5 rows in set
    
  2. Query session variables by CONNECTION_ID.

    obclient> SHOW PROXYSESSION VARIABLES 2147549231;
    +-----------------------------------+------------------+-----------------+--------------------+--------------------------------------------+
    | variable_name                     | value            | info            | modified_type      | sys_variable_flag                          |
    +-----------------------------------+------------------+-----------------+--------------------+--------------------------------------------+
    | ob_proxy_global_variables_version | 1461742173142100 | changed sys var | cold modified vars |  && invisible && session_scope && readonly |
    | ob_proxy_user_privilege           | 65534            | changed sys var | cold modified vars |  && invisible && session_scope && readonly |
    | ob_capability_flag                | 654159           | changed sys var | cold modified vars |  && invisible && session_scope && readonly |
    | ob_enable_transmission_checksum   | 1                | changed sys var | cold modified vars |  && global_scope && session_scope          |
    | _min_cluster_version              | '4.1.0.1'        | user var        | cold modified vars |                                            |
    +-----------------------------------+------------------+-----------------+--------------------+--------------------------------------------+
    5 rows in set
    
  3. Query session variables with the all parameter specified.

    obclient> SHOW PROXYSESSION VARIABLES all 3;
    +-----------------------------------+-----------------------+---------+------------------------------+-----------------------------------------------+
    | variable_name                     | value                 | info    | modified_type                | sys_variable_flag                             |
    +-----------------------------------+-----------------------+---------+------------------------------+-----------------------------------------------+
    | ob_proxy_global_variables_version | 1461742173142100      | sys var | cold modified vars           |  && invisible && session_scope && readonly    |
    | ob_proxy_user_privilege           | 65534                 | sys var | cold modified vars           |  && invisible && session_scope && readonly    |
    | ob_capability_flag                | 654159                | sys var | cold modified vars           |  && invisible && session_scope && readonly    |
    | ob_enable_transmission_checksum   | 1                     | sys var | cold modified vars           |  && global_scope && session_scope             |
    | auto_increment_increment          | 1                     | sys var | cold modified vars           |  && global_scope && session_scope             |
    | auto_increment_offset             | 1                     | sys var | cold modified vars           |  && global_scope && session_scope             |
    ······
    # Subsequent outputs omitted
    

The following table describes the fields in the returned result.

Field Description
variable_name The name of the variable.
value The value of the variable.
info The type of the variable (system variable or user variable).
modified_type The modification type of the variable (identified based on modification frequency).
sys_variable_flag The scope of the system variable.

For more information about system variables, see System variables. For more information about how to set user variables, see SET.

Terminate a client session

You can use the KILL (cs_id | connection_id) command to terminate a client session. The following sections describe how to terminate a client session through the client session ID or connection ID.

Note

If you perform a KILL operation on a session by specifying its cs_id or CONNECTION_ID, the specified session is terminated, indicating that the operation is successful. When you execute the SHOW PROXYSESSION statement, the client will reestablish a session, send the SQL statement to ODP for execution, and display the execution result.

Terminate a session by specifying the client session ID

  1. Execute the SHOW PROXYSESSION statement to query the ID of the client session to be terminated (cs_id).

    obclient> show proxysession;
    

    As shown in the returned result, the value in the second column (Id) indicates the client session ID.

    +---------------------+--------+---------+--------+------+-----------------+------+-------------+-------------------+-------------------+------+------+-----------+
    | proxy_sessid        | Id     | Cluster | Tenant | User | Host            | db   | trans_count | svr_session_count | state             | tid  | pid  | using_ssl |
    +---------------------+--------+---------+--------+------+-----------------+------+-------------+-------------------+-------------------+------+------+-----------+
    | 7230691418559283266 |     68 |  ob1.cc | sys    | root | 127.0.0.1:50260 | NULL |           0 |                 1 | MCS_ACTIVE_READER | 8728 | 8728 |         0 |
    +---------------------+--------+---------+--------+------+-----------------+------+-------------+-------------------+-------------------+------+------+-----------+
    1 rows in set
    
  2. Run the following command to terminate the session:

    obclient> kill 68;
    ERROR 1317 (70100): Query execution was interrupted
    
  3. Execute the following statement to verify whether the session is terminated:

    obclient> select 88;
    

    The returned result shows that the connection is lost.

    ERROR 2013 (HY000): Lost connection to MySQL server during query
    

Terminate a session by specifying the connection ID

  1. Execute the following statement to query the connection ID of the current session:

    obclient> select CONNECTION_ID();
    

    Returned result:

    +-----------------+
    | CONNECTION_ID() |
    +-----------------+
    |      3221766868 |
    +-----------------+
    1 row in set
    
  2. Run the following command to terminate the session:

    obclient> kill 3221766868;
    ERROR 1317 (70100): Query execution was interrupted
    
  3. Execute the following statement to verify whether the session is terminated:

    obclient> select 88;
    

    The returned result shows that the connection is lost.

    ERROR 2013 (HY000): Lost connection to MySQL server during query
    

Previous topic

Session status synchronization
Last

Next topic

Server session
Next
What is on this page
View client sessions
View the details of a client session
View the variables of a client session
Terminate a client session
Terminate a session by specifying the client session ID
Terminate a session by specifying the connection ID