Version sans cache

Mise en cache désactivé. Réglage défaut pour cette page : actif (code DEF204)
Si l'affichage est trop lent, vous pouvez désactiver le mode utilisateur pour visualiser la version en cache.

Rechercher dans le manuel MySQL

26.12.12.1 The data_locks Table

The data_locks table shows data locks held and requested. For information about which lock requests are blocked by which held locks, see Section 26.12.12.2, “The data_lock_waits Table”.

Example data lock information:

  1. mysql> SELECT * FROM performance_schema.data_locks\G
  2. *************************** 1. row ***************************
  3.                ENGINE: INNODB
  4.        ENGINE_LOCK_ID: 139664434886512:1059:139664350547912
  5. ENGINE_TRANSACTION_ID: 2569
  6.             THREAD_ID: 46
  7.              EVENT_ID: 12
  8.         OBJECT_SCHEMA: test
  9.           OBJECT_NAME: t1
  10.        PARTITION_NAME: NULL
  11.     SUBPARTITION_NAME: NULL
  12.            INDEX_NAME: NULL
  13. OBJECT_INSTANCE_BEGIN: 139664350547912
  14.             LOCK_TYPE: TABLE
  15.             LOCK_MODE: IX
  16.           LOCK_STATUS: GRANTED
  17.             LOCK_DATA: NULL
  18. *************************** 2. row ***************************
  19.                ENGINE: INNODB
  20.        ENGINE_LOCK_ID: 139664434886512:2:4:1:139664350544872
  21. ENGINE_TRANSACTION_ID: 2569
  22.             THREAD_ID: 46
  23.              EVENT_ID: 12
  24.         OBJECT_SCHEMA: test
  25.           OBJECT_NAME: t1
  26.        PARTITION_NAME: NULL
  27.     SUBPARTITION_NAME: NULL
  28.            INDEX_NAME: GEN_CLUST_INDEX
  29. OBJECT_INSTANCE_BEGIN: 139664350544872
  30.             LOCK_TYPE: RECORD
  31.             LOCK_MODE: X
  32.           LOCK_STATUS: GRANTED
  33.             LOCK_DATA: supremum pseudo-record

Unlike most Performance Schema data collection, there are no instruments for controlling whether data lock information is collected or system variables for controlling data lock table sizes. The Performance Schema collects information that is already available in the server, so there is no memory or CPU overhead to generate this information or need for parameters that control its collection.

Use the data_locks table to help diagnose performance problems that occur during times of heavy concurrent load. For InnoDB, see the discussion of this topic at Section 15.14.2, “InnoDB INFORMATION_SCHEMA Transaction and Locking Information”.

The data_locks table has these columns:

  • ENGINE

    The storage engine that holds or requested the lock.

  • ENGINE_LOCK_ID

    The ID of the lock held or requested by the storage engine. Tuples of (ENGINE_LOCK_ID, ENGINE) values are unique.

    Lock ID formats are internal and subject to change at any time. Applications should not rely on lock IDs having a particular format.

  • ENGINE_TRANSACTION_ID

    The storage engine internal ID of the transaction that requested the lock. This can be considered the owner of the lock, although the lock might still be pending, not actually granted yet (LOCK_STATUS='WAITING').

    If the transaction has not yet performed any write operation (is still considered read only), the column contains internal data that users should not try to interpret. Otherwise, the column is the transaction ID.

    For InnoDB, to obtain details about the transaction, join this column with the TRX_ID column of the INFORMATION_SCHEMA INNODB_TRX table.

  • THREAD_ID

    The thread ID of the session that created the lock. To obtain details about the thread, join this column with the THREAD_ID column of the Performance Schema threads table.

    THREAD_ID can be used together with EVENT_ID to determine the event during which the lock data structure was created in memory. (This event might have occurred before this particular lock request occurred, if the data structure is used to store multiple locks.)

  • EVENT_ID

    The Performance Schema event that caused the lock. Tuples of (THREAD_ID, EVENT_ID) values implicitly identify a parent event in other Performance Schema tables:

    • The parent wait event in the events_waits_xxx tables

    • The parent stage event in the events_stages_xxx tables

    • The parent statement event in the events_statements_xxx tables

    • The parent transaction event in the events_transactions_current table

    To obtain details about the parent event, join the THREAD_ID and EVENT_ID columns with the columns of like name in the appropriate parent event table. See Section 26.19.2, “Obtaining Parent Event Information”.

  • OBJECT_SCHEMA

    The schema that contains the locked table.

  • OBJECT_NAME

    The name of the locked table.

  • PARTITION_NAME

    The name of the locked partition, if any; NULL otherwise.

  • SUBPARTITION_NAME

    The name of the locked subpartition, if any; NULL otherwise.

  • INDEX_NAME

    The name of the locked index, if any; NULL otherwise.

    In practice, InnoDB always creates an index (GEN_CLUST_INDEX), so INDEX_NAME is non-NULL for InnoDB tables.

  • OBJECT_INSTANCE_BEGIN

    The address in memory of the lock.

  • LOCK_TYPE

    The type of lock.

    The value is storage engine dependent. For InnoDB, permitted values are RECORD for a row-level lock, TABLE for a table-level lock.

  • LOCK_MODE

    How the lock is requested.

    The value is storage engine dependent. For InnoDB, permitted values are S[,GAP], X[,GAP], IS[,GAP], IX[,GAP], AUTO_INC, and UNKNOWN. Lock modes other than AUTO_INC and UNKNOWN indicate gap locks, if present. For information about S, X, IS, IX, and gap locks, refer to Section 15.7.1, “InnoDB Locking”.

  • LOCK_STATUS

    The status of the lock request.

    The value is storage engine dependent. For InnoDB, permitted values are GRANTED (lock is held) and WAITING (lock is being waited for).

  • LOCK_DATA

    The data associated with the lock, if any.

    The value is storage engine dependent. For InnoDB, values are primary key values of the locked record if LOCK_TYPE is RECORD, otherwise NULL. This column contains the values of the primary key columns in the locked row, formatted as a valid SQL string (ready to be copied to SQL statements). If there is no primary key, LOCK_DATA is the unique InnoDB internal row ID number. If a gap lock is taken for key values or ranges above the largest value in the index, LOCK_DATA reports supremum pseudo-record. When the page containing the locked record is not in the buffer pool (in the case that it was paged out to disk while the lock was held), InnoDB does not fetch the page from disk, to avoid unnecessary disk operations. Instead, LOCK_DATA is set to NULL.

The data_locks table has these indexes:

  • Primary key on (ENGINE_LOCK_ID, ENGINE)

  • Index on (ENGINE_TRANSACTION_ID, ENGINE)

  • Index on (THREAD_ID, EVENT_ID)

  • Index on (OBJECT_SCHEMA, OBJECT_NAME, PARTITION_NAME, SUBPARTITION_NAME)

TRUNCATE TABLE is not permitted for the data_locks table.


Rechercher dans le manuel MySQL

Traduction non disponible

Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-data-locks-table.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :en Manuel MySQL : https://dev.mysql.com/

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.

Table des matières Haut