文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 17 InnoDB 存储引擎 / 17.15 InnoDB INFORMATION_SCHEMA 表 / 17.15.2 InnoDB INFORMATION_SCHEMA 事务和锁定信息
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

17.15.2 InnoDB INFORMATION_SCHEMA 事务和锁信息17.15.2 InnoDB INFORMATION_SCHEMA Transaction and Locking Information

一个 INFORMATION_SCHEMA 表和两个 Performance Schema 表让您能够监控 InnoDB 事务并诊断潜在的锁问题:One INFORMATION_SCHEMA table and two Performance Schema tables enable you to monitor InnoDB transactions and diagnose potential locking problems:

  • INNODB_TRX:此 INFORMATION_SCHEMA 表提供有关当前正在 InnoDB 内执行的每个事务的信息,包括事务状态(例如,它是运行中还是在等待锁)、事务开始时间以及事务正在执行的特定 SQL 语句。INNODB_TRX: This INFORMATION_SCHEMA table provides information about every transaction currently executing inside InnoDB, including the transaction state (for example, whether it is running or waiting for a lock), when the transaction started, and the particular SQL statement the transaction is executing.

  • data_locks:此 Performance Schema 表包含每个持有锁和每个因等待已持有的锁而被阻塞的锁请求的行:data_locks: This Performance Schema table contains a row for each hold lock and each lock request that is blocked waiting for a held lock to be released:

    • 对于每个已持有的锁都有一行,无论持有锁的事务状态如何(INNODB_TRX.TRX_STATE 是 RUNNING、LOCK WAIT、ROLLING BACK 或 COMMITTING)。There is one row for each held lock, whatever the state of the transaction that holds the lock (INNODB_TRX.TRX_STATE is RUNNING, LOCK WAIT, ROLLING BACK or COMMITTING).

    • 每个在 InnoDB 中等待其他事务释放锁的事务(INNODB_TRX.TRX_STATE 为 LOCK WAIT)都被一个阻塞锁请求阻止。该阻塞锁请求是针对另一个事务以不兼容模式持有的行或表锁。锁请求始终具有与持有锁阻止该请求的模式不兼容的模式(读与写,共享与独占)。Each transaction in InnoDB that is waiting for another transaction to release a lock (INNODB_TRX.TRX_STATE is LOCK WAIT) is blocked by exactly one blocking lock request. That blocking lock request is for a row or table lock held by another transaction in an incompatible mode. A lock request always has a mode that is incompatible with the mode of the held lock that blocks the request (read vs. write, shared vs. exclusive).

      被阻止的事务无法继续,直到另一个事务提交或回滚,从而释放所请求的锁。对于每个被阻止的事务,data_locks 包含一行,描述事务所请求并正在等待的每个锁。The blocked transaction cannot proceed until the other transaction commits or rolls back, thereby releasing the requested lock. For every blocked transaction, data_locks contains one row that describes each lock the transaction has requested, and for which it is waiting.

  • data_lock_waits:此 Performance Schema 表显示哪些事务正在等待某个锁,或者某个事务正在等待哪个锁。对于每个被阻塞的事务,此表包含一行或多行,显示其请求的锁以及阻塞该请求的任何锁。REQUESTING_ENGINE_LOCK_ID 值指的是事务请求的锁,而 BLOCKING_ENGINE_LOCK_ID 值指的是阻止该事务继续进行的锁(由另一个事务持有)。对于任何给定的被阻塞事务,data_lock_waits 中的所有行 REQUESTING_ENGINE_LOCK_ID 值相同,而 BLOCKING_ENGINE_LOCK_ID 值则不同。data_lock_waits: This Performance Schema table indicates which transactions are waiting for a given lock, or for which lock a given transaction is waiting. This table contains one or more rows for each blocked transaction, indicating the lock it has requested and any locks that are blocking that request. The REQUESTING_ENGINE_LOCK_ID value refers to the lock requested by a transaction, and the BLOCKING_ENGINE_LOCK_ID value refers to the lock (held by another transaction) that prevents the first transaction from proceeding. For any given blocked transaction, all rows in data_lock_waits have the same value for REQUESTING_ENGINE_LOCK_ID and different values for BLOCKING_ENGINE_LOCK_ID.

有关前述表的更多信息,请参见 第 28.4.28 节,“INFORMATION_SCHEMA INNODB_TRX 表”、第 29.12.13.1 节,“data_locks 表” 和 第 29.12.13.2 节,“data_lock_waits 表”。For more information about the preceding tables, see Section 28.4.28, “The INFORMATION_SCHEMA INNODB_TRX Table”, Section 29.12.13.1, “The data_locks Table”, and Section 29.12.13.2, “The data_lock_waits Table”.