Log to disk all queries that waited for a lock over a period of time
You can do this by setting long_query_time as follows:
If you want it done permanently set it in mysql.cnf in the [server] section.
long_query_time=123.123 (down to millisecond precision)
From here - you can also set it dynamically.
Issue the command (from the mysql CLI (Command Line Interface) client):
SHOW VARIABLES LIKE '%long%' 

or similar and set it. You can find out and/or set the destination file by issuing;
SHOW VARIABLES LIKE '%slow%'

Check out the db&lt;&gt;fiddle here!