content_image/806527.jpg content_image/806538.jpg
This section provides information about using the LOCK_ORDER tool, but only at a basic level. For complete details, see the Lock Order section of the MySQL Server Doxygen documentation, available at https://dev.mysql.com/doc/index-other.html. 

The LOCK_ORDER tool is intended for debugging the server, not for production use. 

To use the LOCK_ORDER tool, follow this procedure: 

1. Build MySQL from source, configuring it with the -DWITH_LOCK_ORDER=ON CMake  option so that the build includes LOCK_ORDER tooling. 

<img src='content_image/806527.jpg'>

## Note 

With the WITH_LOCK_ORDER  option enabled, MySQL builds require the flex program. 

2. To run the server with the LOCK_ORDER tool enabled, enable the lock_order  system variable at server startup. Several other system variables for LOCK_ORDER configuration are available as well. 

3. For MySQL test suite operation, mysql-test-run.pl  has a --lock-order  option that controls whether to enable the LOCK_ORDER tool during test case execution. 

The system variables described following configure operation of the LOCK_ORDER tool, assuming that MySQL has been built to include LOCK_ORDER tooling. The primary variable is lock_order , which indicates whether to enable the LOCK_ORDER tool at runtime: 

•If lock_order  is disabled (the default), no other LOCK_ORDER system variables have any effect. 

•If lock_order  is enabled, the other system variables configure which LOCK_ORDER features to enable. 

## Note 

In general, it is intended that the LOCK_ORDER tool be configured by executing mysql-test-run.pl  with the --lock-order  option, and for mysql-test- run.pl  to set LOCK_ORDER system variables to appropriate values. 

All LOCK_ORDER system variables must be set at server startup. At runtime, their values are visible but cannot be changed. 

Some system variables exist in pairs, such as lock_order_debug_loop  and lock_order_trace_loop . For such pairs, the variables are distinguished as follows when the condition occurs with which they are associated: 

•If the _debug_  variable is enabled, a debug assertion is raised. 

•If the _trace_  variable is enabled, an error is printed to the logs. 

<img src='content_image/806538.jpg'>

