eG Monitoring
 

Measures reported by MySQLTabLcWaitTest

A lock is a mechanism associated with a table used to restrict the unauthorized access of the data in a table. MySQL allows a client session to acquire a table lock explicitly to cooperate with other sessions to access the table's data. MySQL also allows table locking to prevent it from unauthorized modification into the same table during a specific period.

A session in MySQL can acquire or release locks on the table only for itself. Therefore, one session cannot acquire or release table locks for other sessions. It is to note that we must have a TABLE LOCK and SELECT privileges for table locking.

Table Locking in MySQL is mainly used to solve concurrency problems. It will be used while running a transaction, i.e., first read a value from a table (database) and then write it into the table (database).

MySQL provides two types of locks onto the table, which are:

READ LOCK: This lock allows a user to only read the data from a table.

WRITE LOCK: This lock allows a user to do both reading and writing into a table.

Table locking enables many sessions to read from a table at the same time, but if a session wants to write to a table, it must first get exclusive access, meaning it might have to wait for other sessions to finish with the table first. During the update, all other sessions that want to access this particular table must wait until the update is done. Table locking causes problems when a session is waiting because the disk is full and free space needs to become available before the session can proceed. In this case, all sessions that want to access the problem table are also put in a waiting state until more disk space is made available. if the number of lock waits grows over time, it will consequently increase the length of the pending requests queue; a long request queue may not only cause the unnecessary erosion of valuable server resources, it may also choke the database server, thereby significantly impacting the quality of the user experience with the server. It is therefore imperative that the lock wait events are monitored, and issues related to such events immediately brought to the attention of administrators.

This test monitors the table lock wait events, and promptly alerts administrators to a sudden/steady increase in the number and duration of such events.

Outputs of the test : One set of results for the target MySQL database server being monitored

The measures made by this test are as follows:

Measurement Description Measurement Unit Interpretation
SessionsWaiting Indicates the number of sessions waiting for the lock during the last measurement period. Number  
MaxLockwaitTime Indicates the maximum time spent by a query while waiting for a table lock. Seconds If the value of this measure is high, there may be an impact on the performance of the database server. To improve the performance, administrators need to optimize the queries, either split one / more tables or use replication.

The detailed diagnosis of this measure lists Thread ID, Statement ID, Schema name, Query duration, Table lock wait time (Seconds), Temp disk tables created, Temp tables created, Rows sent, Rows examined, Select scan, Sort scan and SQL text.