Use it as the entry point when a database is down, slow or rejecting clients.
Database Troubleshooting
Database troubleshooting separates connectivity, authentication, query, locking, resource and storage problems using logs, activity views and plans.
1. Server running? systemctl status postgresql (or mariadb / MSSQLSERVER) and the error log.
2. Connect test from the client host: nc -vz <host> <port>.
3. Activity/blocking views.
4. Slow query and plan.
5. Disk/WAL/log space.
service → network → auth → session → query → locks → storage
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. Preserve the first divergent observation and repeat the same bounded verification after remediation.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
This Topic owns cross-engine triage. Product-specific recovery depth belongs in MariaDB/MySQL, PostgreSQL or SQL Server Topics; host/storage/network causes link to their canonical Domains.
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification workflow Verify boundary
Reproduce one bounded failing connection/query, record timestamp/session/query identity and error code, then move layer by layer from client to engine state. For destructive recovery actions, stop and preserve logs/backup state first; after repair, repeat the same transaction or service-level check.
Step 2 Failure signatures and limits Narrow the fault
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 evidence of data consistency.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Subtopics
Go one level deeper into this subject.
Database connection errors usually come from the network path, the listener, the server's connection limit or authentication rules.
Subtopic Blocking and Long-Running QueriesBlocking happens when one session holds locks others need; long-running queries also consume resources and delay maintenance.
Subtopic Disk Full on Database ServersWhen the data, log or temporary disk fills, the database stops accepting writes and may shut down.
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.
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
ReferenceWhat it is1 section · depth on demand
Operating model
Database Troubleshooting organizes symptoms by boundary: client resolution/network, listener/service, authentication/authorization, session capacity, query/lock engine, storage/log space, replication and recovery. Preserve the first concrete engine/client error before changing configuration.
ReferenceHow it works1 section · depth on demand
In depth
Database troubleshooting starts with the symptom and narrows down to connections, locks, resource limits or specific queries.
| Symptom | First checks |
|---|---|
| Cannot connect | Service running, listen address/port, firewall, pg_hba.conf/host grants, max connections, TLS settings |
| Slow everything | CPU/I/O saturation, memory, locks, checkpoint/log pressure |
| One query slow | Execution plan, statistics, missing index, parameter differences |
| Application hangs | Blocking chains, long-open transactions |
| Disk full | Data growth, log/WAL accumulation (archiving or replica failures), temp files |
| Replica behind | Network, long queries on replica, I/O |
-- PostgreSQL: who blocks whom
SELECT pid, pg_blocking_pids(pid) AS blocked_by, state, left(query,60) FROM pg_stat_activity WHERE cardinality(pg_blocking_pids(pid)) > 0;
-- MariaDB/MySQL
SHOW FULL PROCESSLIST;
SELECT * FROM information_schema.INNODB_TRX\G
Read the database error log early — it usually states exactly why connections are refused or why the server restarted.
ReferenceImportant terms & boundaries1 section · depth on demand
Scope map
- Cannot connect / refused / timeout
- Authentication failures
- Slow query
- Locking/deadlock
- Too many connections
- Disk full / log growth
- Replication lag/failure
- Crash recovery
- Corruption/recovery boundaries
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Configuration & expected output
Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.
Configuration example
Assumptions: Replace host and port.
getent hosts db1
nc -vz db1 5432
pg_isready -h db1 -p 5432
psql "host=db1 dbname=app user=app_ro" -c "SELECT 1;"Expected output
pg_isready -h db1 -p 5432Expected state: The server accepts connections on the expected host and port.
db1:5432 - accepting connections"no response" means network or listener; "rejecting connections" means the server is starting or shutting down; a successful pg_isready still does not prove authentication or pg_hba rules. Illustrative authored output: field layout matches the tool, values will differ in your environment.Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Documentation verification: confirms the upstream model used by the Topic. It does not assert local production behavior.
Basis: https://www.postgresql.org/docs/current/monitoring.html · confidence 92%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Database Troubleshooting verification boundary matrix
A compact lookup separating intent, owning component state, effective state and consumer-visible outcome for Database Troubleshooting.
| 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 |
Deep reference
Design & tradeoffs
Scope
Product-specific recovery depth belongs in MariaDB/MySQL, PostgreSQL or SQL Server Topics; host/storage/network causes link to their canonical Domains.