Database Troubleshooting
Cheat sheet · https://pcornel.dk/topic.php?topic=6097
Answer
Database troubleshooting separates connectivity, authentication, query, locking, resource and storage problems using logs, activity views and plans.
Remember
Read the server error log first. Then: can clients connect? Are sessions blocked? Is a query slow? Is the disk full? Fix the first failing layer.
First checks
systemctl status postgresql— first check for this topicpsql -c "SELECT now(), version();"— PostgreSQL reachable and versionmysql -e "SELECT NOW(), VERSION();"— MariaDB/MySQL reachable and versionsqlcmd -S <server> -Q "SELECT @@VERSION"— SQL Server reachable and version
Verify in this order
service → network → auth → session → query → locks → storage
Where it usually breaks
The most damaging mistakes are restarting before capturing lock/crash state, increasing limits blindly, deleting log/WAL files to free space, breaking replication history during troubleshooting, or treating a recovered engine process as proof of data consistency.
Database Troubleshooting verification boundary matrix
| Boundary | Inspect | Healthy interpretation | Do not infer |
|---|---|---|---|
| Intent | Cannot connect / refused / timeout | Intended object/scope is explicit and versioned where relevant | Intent is already effective |
| Owning runtime/control plane | Authentication failures / Slow query | Owner accepts and reports the expected object state | Downstream dependencies are healthy |
| Effective state | Locking/deadlock | Independent read-back matches the intended state | Every client sees the same result |
| Consumer outcome | Too many connections | The original bounded check succeeds in the same time window | Production correctness outside this scope |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6097