Skip to content

Warning table

When persistWarnings is enabled in the constructor options, warnings are stored in this table. This enables historical tracking and can be used with the pg-boss dashboard for monitoring.

sql
CREATE TABLE pgboss.warning (
  id serial PRIMARY KEY,
  type text NOT NULL,
  message text NOT NULL,
  data jsonb,
  created_on timestamp with time zone NOT NULL DEFAULT now()
)
ColumnDescription
idAuto-incrementing primary key
typeWarning type: slow_query, queue_backlog, or clock_skew
messageHuman-readable warning message
dataJSON object with warning-specific details
created_onTimestamp when the warning was recorded

Querying

sql
-- Recent warnings
SELECT * FROM pgboss.warning ORDER BY created_on DESC LIMIT 100;

-- Warnings by type
SELECT * FROM pgboss.warning WHERE type = 'queue_backlog' ORDER BY created_on DESC;

-- Warnings from the last hour
SELECT * FROM pgboss.warning WHERE created_on > now() - interval '1 hour';

Cleanup

To enable automatic cleanup, set the warningRetentionDays option:

js
const boss = new PgBoss({
  connectionString: 'postgres://...',
  persistWarnings: true,
  warningRetentionDays: 30
});

Warnings are pruned during the regular maintenance cycle (controlled by maintenanceIntervalSeconds).

For manual cleanup:

sql
DELETE FROM pgboss.warning WHERE created_on < now() - interval '30 days';