# How to Investigate MySQL and MariaDB Lock Waits

https://ferkesh.net/uk/baza-znan/stattia/mysql-mariadb-lock-wait-incident

![Workflow: Collect a narrow record; Inspect through approved access; Reproduce safely; Verify and escalate.](https://ferkesh.net/kb-media/ferkesh-guide-diagrams-batch-12.svg#mysql-mariadb-lock-wait-incident)

A database operation waiting on another transaction can look like a slow server. Increasing a timeout can hide the symptom while more requests accumulate.

## Procedure

1. **Collect a narrow record.** Note the database version, affected request, timestamp and error code. Compare application, worker and database timing. Keep sensitive SQL and values out of shared notes.
2. **Inspect through approved access.** Use the server version’s documented lock-wait views or ask the DBA for a redacted sample. Identify the waiting and blocking transaction and whether a long-running job or migration is active.
3. **Reproduce safely.** On staging, compare the transaction scope, query plan and indexes. Test smaller batches or a shorter transaction while preserving the expected consistency semantics.
4. **Verify and escalate.** Rerun the original workload and review wait duration and errors. Escalate any proposed live session termination to the responsible DBA with the transaction and impact documented.

If two sessions show different row behavior, [compare MariaDB transaction isolation across connections](https://ferkesh.net/knowledgebase/article/mariadb-transaction-isolation-audit) before changing lock timeouts or retry logic.

## Related guides

- [How Database Connection Limits Differ from Bandwidth Limits](https://ferkesh.net/knowledgebase/article/database-connections-vs-bandwidth)
- [How to Plan Rollback for a Database Schema Change](https://ferkesh.net/knowledgebase/article/database-schema-rollback-checklist)
- [Developer Resources articles](https://ferkesh.net/knowledgebase/category/developer-resources)

## Official references

- [MySQL InnoDB lock and lock-wait information](https://dev.mysql.com/doc/refman/8.4/en/innodb-information-schema-understanding-innodb-locking.html)
- [MariaDB InnoDB lock waits](https://mariadb.com/docs/server/reference/system-tables/information-schema/information-schema-tables/information-schema-innodb-tables/information-schema-innodb_lock_waits-table)

Ferkesh Hosting. Last reviewed November 26, 2026.
