Managing user sessions is a core DBA skill in any gbase database. When performance dips or resources are tight, knowing how to list connections and terminate problematic ones safely keeps your cluster running smoothly.
1. Viewing All Connected Sessions
Option A: SHOW PROCESSLIST
A quick overview of threads on the current coordinator.
SHOW PROCESSLIST;
Key columns:
-
Id – the unique session identifier, used later with
KILL. - User, Host – who is connected and from where.
- Time – seconds the session or current query has been running.
-
State – e.g.,
Sleep(idle),Query(executing). - Info – the running SQL; empty means the session is idle.
Option B: information_schema.processlist (Recommended)
This view supports filtering and sorting, making it the go‑to for analysis.
SELECT id, user, host, db, command, time, state, info
FROM information_schema.processlist
WHERE command != 'Sleep'
ORDER BY time DESC;
Use it to quickly spot long‑running, resource‑heavy sessions.
2. Safely Terminating a Problem Session
Before running any kill command, identify the right session and choose the least disruptive method.
Termination Options
| Command | Effect | When to Use | Impact |
|---|---|---|---|
KILL CONNECTION <id> (or KILL <id>) |
Disconnects the session, rolls back uncommitted work | Frozen sessions, unresponsive connections | High |
KILL QUERY <id> |
Cancels only the current SQL statement, keeps the connection alive | A runaway query that doesn't need a full disconnect | Lower |
PAUSE <id> / CONTINUE <id>
|
Temporarily pauses / resumes execution | Quick resource relief for diagnostics | Minimal |
Examples:
-- Terminate the entire session
KILL 5593;
-- Cancel only the running query
KILL QUERY 5593;
Safe Procedure
- Identify: find queries running longer than 5 minutes.
SELECT id, user, time, state, info
FROM information_schema.processlist
WHERE command = 'Query' AND time > 300
ORDER BY time DESC;
-
Evaluate: check
State(Sending data,Sorting result) and review the SQL inInfofor anomalies. -
Kill: prefer
KILL QUERYto preserve the connection; escalate toKILL CONNECTIONonly if needed. -
Verify: run
SHOW PROCESSLISTagain to confirm the session is gone or its state has changed.
3. Important Notes
-
Privileges:
PROCESSis required to view all sessions;SUPER(or equivalent) is needed forKILL. - Multi‑VC clusters: switch to the target VC first:
USE VC vc_name;
SHOW PROCESSLIST;
-
Prevention: use resource pools to cap per‑query resources, set
task_running_timeoutto auto‑cancel long queries, and leverage GDOM for visual monitoring.
The golden rule for terminating sessions: diagnose first, then act; use KILL QUERY whenever possible. This keeps your gbase database healthy while minimizing business disruption.
Top comments (0)