Skip to content

Triage with SHOW PROCESSLIST on a cPanel MySQL host — what each State means

PROCESSLIST is the first command in any MySQL triage. The State column tells you whether the connection is busy, blocked, or stuck — but only if you can read the vocabulary.

Every MySQL triage starts with SHOW PROCESSLIST. The columns make sense at a glance — except for State, which is a glossary of MySQL internals. “Waiting for table metadata lock” means one thing; “Sending data” means something else; “Updating” sounds like progress but often isn’t. Picking the right next move (KILL, wait, escalate) requires reading the State column correctly. On a busy cPanel host with 200 active connections, the wrong interpretation extends an incident.

What’s happening

SHOW PROCESSLIST (or SELECT * FROM information_schema.PROCESSLIST for the full SQL in Info) lists every active connection. State values you actually see in practice:

  • Sleep — connection is idle, waiting for the client to send its next query. Counts toward max_connections and max_user_connections but uses minimal CPU. A high count of Sleep is usually persistent connections from PHP-FPM. Not a problem.
  • Sending data — actively executing a query and streaming results. Most “long running” queries spend most of their time here. Misleading name: it includes time spent reading from disk, not just sending bytes back.
  • Updating — applying changes to a table. INSERT, UPDATE, DELETE all show this.
  • Sorting result — performing a sort (ORDER BY). If this lasts more than a few seconds on a small table, the sort buffer is too small or the query needs an index.
  • Locked / Waiting for table metadata lock — blocked waiting for another connection to release a lock. The blocker is somewhere else in the list.
  • Waiting for table flush — blocked because FLUSH TABLES or a backup is running and holding a table.
  • Copying to tmp table / Copying to tmp table on disk — the query is materializing intermediate results. On disk version means the in-memory temp table exceeded tmp_table_size and spilled. Usually means the query needs rewriting.
  • Creating sort index — building a temporary index for sorting. Often a sign of a missing real index.
  • Killed — a KILL was issued but the connection hasn’t finished cleanup yet. Usually clears within seconds; if it persists, the cleanup is stuck (rare).

The Time column is “seconds in the current state.” A query in Sleep for 3000 seconds is fine; a query in Sending data for 3000 seconds is the suspect.

How to verify

mysql -e "SHOW FULL PROCESSLIST" | head -40
mysql -e "SELECT id, user, db, command, time, state, LEFT(info, 80) FROM information_schema.PROCESSLIST WHERE command != 'Sleep' ORDER BY time DESC LIMIT 20"
mysql -e "SELECT state, COUNT(*) FROM information_schema.PROCESSLIST GROUP BY state ORDER BY 2 DESC"
mysql -e "SELECT * FROM information_schema.INNODB_LOCK_WAITS"  # MySQL 5.7
mysql -e "SELECT * FROM performance_schema.data_lock_waits"  # MySQL 8.0+

The first three are the broad triage. The lock_waits query identifies the blocker-blocked pairs for any waiting connection.

The fix

  1. Group by State first. GROUP BY state shows what’s dominant. 200 connections in Sleep is fine. 50 connections in Waiting for table metadata lock is a lock storm.
  2. For lock storms, find the blocker. The connection holding the lock is the one whose query started earliest (sort by time DESC or look at information_schema.INNODB_TRX.trx_started). KILL QUERY on the blocker releases the queue.
  3. For Sending data with long times, run EXPLAIN on the SQL. Likely a missing index. Don’t KILL routinely — analytics queries legitimately take minutes. Investigate first, KILL only if it’s blocking foreground work.
  4. For Copying to tmp table on disk, the immediate fix is to KILL and let the application retry. The longer fix is to raise tmp_table_size and max_heap_table_size to fit the intermediate result in RAM, or rewrite the query to avoid the temp table.
  5. For high Sleep count without other issues, no action needed. If sleeping connections are pushing max_user_connections for one account, that account’s PHP-FPM has too many children or persistent connections. PHP-side fix.
  6. For State that doesn’t match the documentation, you’re probably on a version with a new state name. MariaDB 10.x and MySQL 8.x have added several new states for InnoDB internals. Check the version-specific manual.
  7. Automate the triage:
    while true; do
      date
      mysql -e "SELECT state, COUNT(*) FROM information_schema.PROCESSLIST GROUP BY state ORDER BY 2 DESC LIMIT 10"
      sleep 5
    done
    Snapshot every 5 seconds during an incident. Patterns are easier to see in a sequence.

For environments where MySQL diagnostic literacy varies across the team, Stack Harbor’s environment management team builds a runbook that maps each common State to a triage decision and ships dashboards that surface lock waits before they become incidents.