Databases 6 min read

MySQL 5.7 Monitoring and Troubleshooting Guide: Connections, Long Transactions, Metadata Locks, and More

This guide provides a comprehensive overview of MySQL 5.7 monitoring techniques, covering connection parameters, long‑running transactions, metadata lock tracing, lock‑wait analysis, global read locks, memory usage, partitioned tables, database size summaries, table update status, primary key and index considerations, storage engine distribution, and real‑time load metrics.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
MySQL 5.7 Monitoring and Troubleshooting Guide: Connections, Long Transactions, Metadata Locks, and More

1. Connection Related Shows how to view session‑level parameters and status variables for a specific user connection (e.g., character set settings for connection ID 19) or all connections, helping diagnose connection‑related issues.

2. Long Transactions Identifies sessions that have held a transaction open for more than 5 seconds without committing, which can block DDL operations.

3. Metadata Locks (MDL) Describes enabling MDL tracing in MySQL 5.7 to locate lock‑related blocking problems, and provides examples of killing sessions that hold MDL locks to allow DDL statements to proceed.

4. Lock Waits Explains how to view blocking and blocked threads, including user, IP, and port information, and notes that the innodb_lock_waits table can be queried directly when detailed user data is not needed.

5. Global Read Locks Details the performance_schema.metadata_locks table columns that indicate explicit FTWRL locks and how to kill sessions that added such locks to restore normal operation.

6. Memory Usage Monitoring Notes that only the performance_schema database is monitored by default; enabling global memory statistics requires manual configuration, and provides views for locating memory‑related issues.

7. Partitioned Tables Shows how to list partitioned tables in an instance and retrieve detailed information for a specific partitioned table (e.g., database db, table e).

8. Database Overview Provides queries to summarize the size of each database, the size of tables within a database, and basic table information.

9. Tables Not Updated for a Long Time Indicates that a NULL UPDATE_TIME means the table has not been updated since the instance started.

10. Primary Keys and Indexes Discusses the impact of missing primary keys, unique keys, or secondary indexes on InnoDB performance, replication lag, and full‑table scans.

11. Storage Engine Distribution Shows the distribution of storage engines used by tables and highlights non‑InnoDB tables.

12. Real‑Time Load Provides a snapshot of current load metrics to assess the instance’s performance at a glance.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

SQLmysqltroubleshooting
Aikesheng Open Source Community
Written by

Aikesheng Open Source Community

The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.