Pcornel
Databases

Database Troubleshooting

Cheat sheet · https://pcornel.dk/topic.php?topic=6097

Back to the Topic

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 topic
  • psql -c "SELECT now(), version();" — PostgreSQL reachable and version
  • mysql -e "SELECT NOW(), VERSION();" — MariaDB/MySQL reachable and version
  • sqlcmd -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

BoundaryInspectHealthy interpretationDo not infer
IntentCannot connect / refused / timeoutIntended object/scope is explicit and versioned where relevantIntent is already effective
Owning runtime/control planeAuthentication failures / Slow queryOwner accepts and reports the expected object stateDownstream dependencies are healthy
Effective stateLocking/deadlockIndependent read-back matches the intended stateEvery client sees the same result
Consumer outcomeToo many connectionsThe original bounded check succeeds in the same time windowProduction 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

Confirmation

Confirm action

Continue?