Skip to content

This is the multi-page printable view of this section. .

Return to the regular view of this page.

Activity waits

Background processes sleeping in their main loop until work arrives.

Activity is mostly the sound of a healthy idle background process. Archiver, checkpointer, WAL writer, autovacuum launcher, replication workers, and related processes publish distinct names while waiting in their main loop.

Interpret by backend type

These events should not be counted in a foreground “waiting session percentage.” Instead, compare the event with backend_type and ask whether that process should currently have work.

  • Normal: one matching background process waits in its documented main loop.
  • Watch: the event appears on the wrong backend type, the process is absent, or work queues grow while it remains idle.
  • Urgent: required background progress has stopped—archiving backlog, no checkpoints, replication not advancing, or shutdown unable to finish.

Events to recognize

Event Expected process
AutovacuumMain Autovacuum launcher between scheduling cycles
CheckpointerMain Checkpointer awaiting work
WalWriterMain WAL writer main loop
ArchiverMain Archiver waiting for a completed segment
WalReceiverMain WAL receiver main loop
RecoveryWalStream Startup process waiting for streamed WAL
IoWorkerMain PG18 asynchronous I/O worker awaiting work

Common misreads

  • Activity waits dominating all backends can simply mean the cluster is idle.
  • An idle checkpointer is not evidence that checkpoints are disabled.
  • A normal wait name does not prove progress; check the queue/backlog and timestamps.
  • Missing expected background processes is often more important than seeing their Activity wait.

1 - Activity: ArchiverMain

Waiting in main loop of archiver process
PostgreSQL wait event dossier
ClassActivity EventArchiverMain VersionsPG 13-18 Evidence2 source location(s)

Official description

Waiting in main loop of archiver process

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_ARCHIVER_MAIN at src/backend/postmaster/pgarch.c:362 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:54. The instrumented operation is: Waiting in main loop of archiver process. The ArchiverMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/ArchiverMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'ArchiverMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'ArchiverMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

2 - Activity: AutovacuumMain

Waiting in main loop of autovacuum launcher process
PostgreSQL wait event dossier
ClassActivity EventAutovacuumMain VersionsPG 17-18 Evidence4 source location(s)

Official description

Waiting in main loop of autovacuum launcher process

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Earlier names: Activity/AutoVacuumMain (PG 13-16)

Trigger mechanism

WAIT_EVENT_AUTOVACUUM_MAIN at src/backend/postmaster/autovacuum.c:667 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event.c:216. The instrumented operation is: Waiting in main loop of autovacuum launcher process. The AutovacuumMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/AutovacuumMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'AutovacuumMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'AutovacuumMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

3 - Activity: BgwriterHibernate

Waiting in background writer process, hibernating
PostgreSQL wait event dossier
ClassActivity EventBgwriterHibernate VersionsPG 17-18 Evidence4 source location(s)

Official description

Waiting in background writer process, hibernating

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Earlier names: Activity/BgWriterHibernate (PG 13-16)

Trigger mechanism

WAIT_EVENT_BGWRITER_HIBERNATE at src/backend/postmaster/bgwriter.c:339 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event.c:219. The instrumented operation is: Waiting in background writer process, hibernating. The BgwriterHibernate background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/BgwriterHibernate
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'BgwriterHibernate'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'BgwriterHibernate'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

4 - Activity: BgwriterMain

Waiting in main loop of background writer process
PostgreSQL wait event dossier
ClassActivity EventBgwriterMain VersionsPG 17-18 Evidence4 source location(s)

Official description

Waiting in main loop of background writer process

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Earlier names: Activity/BgWriterMain (PG 13-16)

Trigger mechanism

WAIT_EVENT_BGWRITER_MAIN at src/backend/postmaster/bgwriter.c:311 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event.c:222. The instrumented operation is: Waiting in main loop of background writer process. The BgwriterMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/BgwriterMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'BgwriterMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'BgwriterMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

5 - Activity: CheckpointerMain

Waiting in main loop of checkpointer process
PostgreSQL wait event dossier
ClassActivity EventCheckpointerMain VersionsPG 13-18 Evidence2 source location(s)

Official description

Waiting in main loop of checkpointer process

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_CHECKPOINTER_MAIN at src/backend/postmaster/checkpointer.c:583 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:58. The instrumented operation is: Waiting in main loop of checkpointer process. The CheckpointerMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/CheckpointerMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'CheckpointerMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'CheckpointerMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

6 - Activity: CheckpointerShutdown

Waiting for checkpointer process to be terminated
PostgreSQL wait event dossier
ClassActivity EventCheckpointerShutdown VersionsPG 18 Evidence2 source location(s)

Official description

Waiting for checkpointer process to be terminated

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_CHECKPOINTER_SHUTDOWN at src/backend/postmaster/checkpointer.c:631 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:59. The instrumented operation is: Waiting for checkpointer process to be terminated. The CheckpointerShutdown background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/CheckpointerShutdown
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'CheckpointerShutdown'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'CheckpointerShutdown'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

7 - Activity: IoWorkerMain

Waiting in main loop of IO Worker process
PostgreSQL wait event dossier
ClassActivity EventIoWorkerMain VersionsPG 18 Evidence2 source location(s)

Official description

Waiting in main loop of IO Worker process

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_IO_WORKER_MAIN at src/backend/storage/aio/method_worker.c:573 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:60. The instrumented operation is: Waiting in main loop of IO Worker process. The IoWorkerMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/IoWorkerMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'IoWorkerMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'IoWorkerMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

8 - Activity: LogicalApplyMain

Waiting in main loop of logical replication apply process
PostgreSQL wait event dossier
ClassActivity EventLogicalApplyMain VersionsPG 13-18 Evidence2 source location(s)

Official description

Waiting in main loop of logical replication apply process

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_LOGICAL_APPLY_MAIN at src/backend/replication/logical/worker.c:3766 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:61. The instrumented operation is: Waiting in main loop of logical replication apply process. The LogicalApplyMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/LogicalApplyMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'LogicalApplyMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'LogicalApplyMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

9 - Activity: LogicalLauncherMain

Waiting in main loop of logical replication launcher process
PostgreSQL wait event dossier
ClassActivity EventLogicalLauncherMain VersionsPG 13-18 Evidence2 source location(s)

Official description

Waiting in main loop of logical replication launcher process

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_LOGICAL_LAUNCHER_MAIN at src/backend/replication/logical/launcher.c:1242 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:62. The instrumented operation is: Waiting in main loop of logical replication launcher process. The LogicalLauncherMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/LogicalLauncherMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'LogicalLauncherMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'LogicalLauncherMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

10 - Activity: LogicalParallelApplyMain

Waiting in main loop of logical replication parallel apply process
PostgreSQL wait event dossier
ClassActivity EventLogicalParallelApplyMain VersionsPG 16-18 Evidence2 source location(s)

Official description

Waiting in main loop of logical replication parallel apply process

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_LOGICAL_PARALLEL_APPLY_MAIN at src/backend/replication/logical/applyparallelworker.c:810 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:63. The instrumented operation is: Waiting in main loop of logical replication parallel apply process. The LogicalParallelApplyMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/LogicalParallelApplyMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'LogicalParallelApplyMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'LogicalParallelApplyMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

11 - Activity: PgStatMain

Waiting in main loop of statistics collector process.
PostgreSQL wait event dossier
ClassActivity EventPgStatMain VersionsPG 13-14 Evidence2 source location(s)

Official description

Waiting in main loop of statistics collector process.

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_PGSTAT_MAIN at src/backend/postmaster/pgstat.c:3425 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event.c:234. The instrumented operation is: Waiting in main loop of statistics collector process. The PgStatMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/PgStatMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'PgStatMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'PgStatMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

12 - Activity: RecoveryWalStream

Waiting in main loop of startup process for WAL to arrive, during streaming recovery
PostgreSQL wait event dossier
ClassActivity EventRecoveryWalStream VersionsPG 13-18 Evidence2 source location(s)

Official description

Waiting in main loop of startup process for WAL to arrive, during streaming recovery

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_RECOVERY_WAL_STREAM at src/backend/access/transam/xlogrecovery.c:4038 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:64. The instrumented operation is: Waiting in main loop of startup process for WAL to arrive, during streaming recovery. The RecoveryWalStream background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/RecoveryWalStream
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'RecoveryWalStream'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'RecoveryWalStream'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

13 - Activity: ReplicationSlotsyncMain

Waiting in main loop of slot sync worker
PostgreSQL wait event dossier
ClassActivity EventReplicationSlotsyncMain VersionsPG 17-18 Evidence2 source location(s)

Official description

Waiting in main loop of slot sync worker

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_REPLICATION_SLOTSYNC_MAIN at src/backend/replication/logical/slotsync.c:1369 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:65. The instrumented operation is: Waiting in main loop of slot sync worker. The ReplicationSlotsyncMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/ReplicationSlotsyncMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'ReplicationSlotsyncMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'ReplicationSlotsyncMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

14 - Activity: ReplicationSlotsyncShutdown

Waiting for slot sync worker to shut down
PostgreSQL wait event dossier
ClassActivity EventReplicationSlotsyncShutdown VersionsPG 17-18 Evidence2 source location(s)

Official description

Waiting for slot sync worker to shut down

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_REPLICATION_SLOTSYNC_SHUTDOWN at src/backend/replication/logical/slotsync.c:1732 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:66. The instrumented operation is: Waiting for slot sync worker to shut down. The ReplicationSlotsyncShutdown background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/ReplicationSlotsyncShutdown
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'ReplicationSlotsyncShutdown'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'ReplicationSlotsyncShutdown'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

15 - Activity: SysloggerMain

Waiting in main loop of syslogger process
PostgreSQL wait event dossier
ClassActivity EventSysloggerMain VersionsPG 17-18 Evidence4 source location(s)

Official description

Waiting in main loop of syslogger process

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Earlier names: Activity/SysLoggerMain (PG 13-16)

Trigger mechanism

WAIT_EVENT_SYSLOGGER_MAIN at src/backend/postmaster/syslogger.c:487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event.c:240. The instrumented operation is: Waiting in main loop of syslogger process. The SysloggerMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/SysloggerMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'SysloggerMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'SysloggerMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

16 - Activity: WalReceiverMain

Waiting in main loop of WAL receiver process
PostgreSQL wait event dossier
ClassActivity EventWalReceiverMain VersionsPG 13-18 Evidence2 source location(s)

Official description

Waiting in main loop of WAL receiver process

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_WAL_RECEIVER_MAIN at src/backend/replication/walreceiver.c:600 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:68. The instrumented operation is: Waiting in main loop of WAL receiver process. The WalReceiverMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/WalReceiverMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'WalReceiverMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'WalReceiverMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

17 - Activity: WalSenderMain

Waiting in main loop of WAL sender process
PostgreSQL wait event dossier
ClassActivity EventWalSenderMain VersionsPG 13-18 Evidence2 source location(s)

Official description

Waiting in main loop of WAL sender process

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_WAL_SENDER_MAIN at src/backend/replication/walsender.c:2963 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:69. The instrumented operation is: Waiting in main loop of WAL sender process. The WalSenderMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/WalSenderMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'WalSenderMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'WalSenderMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

18 - Activity: WalSummarizerWal

Waiting in WAL summarizer for more WAL to be generated
PostgreSQL wait event dossier
ClassActivity EventWalSummarizerWal VersionsPG 17-18 Evidence2 source location(s)

Official description

Waiting in WAL summarizer for more WAL to be generated

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_WAL_SUMMARIZER_WAL at src/backend/postmaster/walsummarizer.c:1798 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:70. The instrumented operation is: Waiting in WAL summarizer for more WAL to be generated. The WalSummarizerWal background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/WalSummarizerWal
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'WalSummarizerWal'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'WalSummarizerWal'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence

19 - Activity: WalWriterMain

Waiting in main loop of WAL writer process
PostgreSQL wait event dossier
ClassActivity EventWalWriterMain VersionsPG 13-18 Evidence2 source location(s)

Official description

Waiting in main loop of WAL writer process

PG 13 PG 14 PG 15 PG 16 PG 17 PG 18

Trigger mechanism

WAIT_EVENT_WAL_WRITER_MAIN at src/backend/postmaster/walwriter.c:271 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:71. The instrumented operation is: Waiting in main loop of WAL writer process. The WalWriterMain background path reports this event around its latch wait when its main loop has no immediate work. A signal, timeout, or new work clears the sleep and the process loops again.

Normal or trouble?

  • Normal: This is normally expected idleness for the matching background process.
  • Investigate: Investigate only when queued work or a shutdown/failover deadline is not advancing while the process remains here, or when the event appears on an unexpected backend type.

Diagnostic SQL

Sessions waiting on Activity/WalWriterMain
SELECT pid, backend_type, usename, datname, application_name,
       state, now() - query_start AS query_age,
       now() - xact_start AS xact_age,
       wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocking_pids,
       left(query, 160) AS query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
  AND wait_event = 'WalWriterMain'
ORDER BY query_age DESC NULLS LAST;
Current Activity cohort
SELECT wait_event, count(*) AS waiting_sessions,
       count(*) FILTER (WHERE state = 'active') AS active_waiters,
       max(now() - query_start) AS oldest_query
FROM pg_stat_activity
WHERE wait_event_type = 'Activity'
GROUP BY wait_event
ORDER BY waiting_sessions DESC, wait_event;
Lock and relation context for these sessions
SELECT a.pid, l.locktype, l.mode, l.granted, l.fastpath,
       d.datname, n.nspname, c.relname,
       l.page, l.tuple, l.virtualxid, l.transactionid,
       l.classid, l.objid, l.objsubid
FROM pg_stat_activity AS a
LEFT JOIN pg_locks AS l ON l.pid = a.pid
LEFT JOIN pg_database AS d ON d.oid = l.database
LEFT JOIN pg_class AS c
  ON c.oid = l.relation
 AND l.database = (
       SELECT oid FROM pg_database WHERE datname = current_database()
     )
LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE a.wait_event_type = 'Activity'
  AND a.wait_event = 'WalWriterMain'
ORDER BY a.pid, l.granted, l.locktype, l.mode;

Response

  1. Match the row to backend_type.
  2. Inspect the process-specific backlog and last-progress timestamp.
  3. Fix the missing work signal or stalled upstream phase; do not kill a normally idle worker.

Source evidence