Build a point-in-time correct training set and block feature leakage
Join features to labels as they were known at each label's cutoff with a DuckDB ASOF join, audit the set for future rows and correlation lift, then publish it or block it.
Monitors PostgreSQL datfrozenxid transaction age to detect autovacuum wraparound risk before database enters emergency read-only mode.
PostgreSQL employs 32-bit transaction IDs (XIDs), creating a maximum circular sequence limit of approximately 4 billion transactions. To prevent transaction wraparound, where past committed tuples appear to be in the future, PostgreSQL reserves 2 billion transactions for past visibility and continuously freezes older tuples via the autovacuum daemon.
If autovacuum workers are impeded by long-running transactions, lock contention, or heavy write workloads, transaction age (age(datfrozenxid)) continues to climb toward the 2.14 billion freeze horizon. When transaction age crosses the critical threshold (usually 2.0 billion transactions), PostgreSQL shuts down completely, refusing all new insert, update, and DDL commands, and only permits manual VACUUM FREEZE operations in single-user maintenance mode.
This blueprint implements an automated database durability guard that queries pg_database daily, computes transaction age percentages across all active databases, and dispatches high-urgency Slack notifications before critical freeze horizons are reached.
daily_wraparound_check trigger (io.kestra.plugin.core.trigger.Schedule) executes daily at 03:00 UTC.query_database_freeze_horizon task (io.kestra.plugin.jdbc.postgresql.Query) executes SQL against pg_database to calculate age(datfrozenxid) and capacity percentages.analyze_wraparound_risk task (io.kestra.plugin.scripts.python.Script) checks databases against freeze_max_age_warning_threshold (default: 1.5 billion transactions) and exports wraparound_report.json.evaluate_risk_condition flowable task (io.kestra.plugin.core.flow.If) branches based on whether any database breached warning boundaries.alert_dba_team_on_wraparound_risk (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) delivers an actionable triage card with step-by-step remediation advice.export_wraparound_manifest task records execution state for compliance records.flowchart TD
A[Schedule: Daily 03:00 UTC] --> B[query_database_freeze_horizon: PostgreSQL]
B --> C[analyze_wraparound_risk: Python Risk Analyzer]
C --> D{Wraparound Threshold Breached?}
D -- Yes --> E[alert_dba_team_on_wraparound_risk: Slack]
D -- No --> F[log_compliant_wraparound_status: Log]
E --> G[export_wraparound_manifest: Return JSON]
F --> G
Monitoring internal PostgreSQL freeze limits through standard APM tools often requires complex custom agent scripts. Kestra combines native PostgreSQL JDBC connectivity, isolated container execution, and rich Slack integrations into a declarative workflow that DBAs can audit and schedule effortlessly.
| Name | Type | Default | Description |
|---|---|---|---|
postgres_url |
STRING | jdbc:postgresql://... |
JDBC URL of the target PostgreSQL database cluster. |
postgres_username |
STRING | db_monitor |
Database monitoring user with catalog access. |
freeze_max_age_warning_threshold |
INT | 1500000000 |
Warning transaction age (default 1.5 billion). |
slack_channel |
STRING | #dba-alerts |
Slack channel destination for alerts. |
{{ outputs.analyze_wraparound_risk.vars.wraparound_risk_detected }}: Boolean flag indicating if any database breached threshold.{{ outputs.analyze_wraparound_risk.vars.highest_age_database }}: Name of the database with the oldest freeze age.{{ outputs.analyze_wraparound_risk.vars.highest_age_value }}: Current transaction age of the top offender.{{ outputs.analyze_wraparound_risk.outputFiles['wraparound_report.json'] }}: Complete JSON diagnostic report.POSTGRES_PASSWORD: Password for the PostgreSQL database user.SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL.POSTGRES_PASSWORD and SLACK_WEBHOOK_URL in your Kestra namespace secrets.pg_prepared_xacts) hold back the global freeze horizon; investigate idle transactions alongside table freezes.SELECT FOR UPDATE), check age(datminmxid) in addition to datfrozenxid.autovacuum_max_workers and autovacuum_vacuum_cost_limit are tuned to prevent vacuum backlog accumulation.io.kestra.plugin.jdbc.postgresql.Query to inspect individual table ages via pg_class.relfrozenxid for the highest-age database.autovacuum_vacuum_cost_limit via ALTER SYSTEM during scheduled weekend maintenance windows.