Clear Pulsar backlogs held by subscriptions nobody consumes
Detect Apache Pulsar subscriptions with no consumers that still pin a large backlog, then clear or remove them behind a dry run, an approval pause and a live re-read that fails the run.
Detect RANGE partitioned PostgreSQL tables missing future partitions, create them behind an approval gate, then re-read the partition tree to confirm.
A RANGE partitioned table splits its rows across child tables by a time range. Someone has to create next week's partitions before next week arrives. When nobody does, every new row either falls into the DEFAULT partition, which then grows without bound and cannot be split later without an exclusive lock or, with no DEFAULT, the insert fails with "no partition of relation found for row". Either way it is a day-2 outage waiting on the calendar. This guard reads the live partition tree, works out which of the next N windows have no covering partition, creates the missing ones under a gate and proves they landed.
This blueprint was created by zkasuran.
dry_run is true and auto_remediate is false, so a plain run reports and never creates a partition.auto_remediate is true and dry_run is false. It then waits for a human to resume the Pause with approved set true. An unanswered gate reads as not approved.detect (io.kestra.plugin.jdbc.postgresql.Query) reads pg_partitioned_table for RANGE parents keyed on one date or timestamp column, enumerates each parent's children through pg_inherits, parses the FROM and TO bounds from pg_get_expr, builds the next windows_ahead windows from date_trunc(window_size, now()) and returns one row per window no partition covers. Each row carries the deterministic child name and the exact CREATE TABLE PARTITION OF statement, built with format('%I') and format('%L') so identifiers and bounds are quoted by the database.summarize (io.kestra.plugin.core.output.OutputValues) builds the human readable target list and the JSON the loop iterates, so the log, the alert and the loop read the same set.log_detect (io.kestra.plugin.core.log.Log) logs the count, the targets and the mode.guard (io.kestra.plugin.core.flow.If) branches on the count. With none found, clean logs and the run ends. Otherwise findings_alert posts the finding on every detection.mode (io.kestra.plugin.core.flow.If) enters the remediation branch only when auto_remediate is true and dry_run is false. Otherwise report_only lists what would be created and stops.approval_gate (io.kestra.plugin.core.flow.Pause) holds the run until a human resumes it. create_partitions (io.kestra.plugin.core.flow.Loop, concurrencyLimit: 1) then runs one CREATE TABLE PARTITION OF per target.reverify re-runs the detection and verify_result fails the run through io.kestra.plugin.core.execution.Fail if any targeted window is still uncovered. A window that rolled in during the run is not a target, so it does not fail the run.<parent>_YYYYMMDD) and a CREATE built inside PostgreSQL, correct for date, timestamp and timestamptz keys.PostgreSQL has no scheduler, no dry run, no approval step and no way to prove a partition was created. pg_partman solves the scheduling with an extension you have to install and trust. A hand-rolled cron creates blindly and says nothing when a create is rejected. Kestra adds the missing pieces. It schedules the sweep, computes the exact missing windows from the live partition tree, gates the change behind dry-run and approval, builds each CREATE inside the database so identifiers and bounds are correct, re-reads the tree to turn a hopeful create into a verified one and posts a Slack alert the moment a step fails.
Run on Kestra 2.0.5 against a PostgreSQL 16 server, with a local HTTP sink standing in for Slack. One schema held four tables: events_default partitioned by day with a DEFAULT partition and days behind through tomorrow provisioned, events_strict partitioned by day with no DEFAULT and only today and tomorrow provisioned, metrics_full partitioned by day and already provisioned for the next seven days, plus a plain non-partitioned table. A LIST partitioned table was also present. Every count was confirmed with psql against pg_partition_tree.
windows_ahead 7 the detector returned exactly 10 uncovered windows (five on each of the two under-provisioned tables), never metrics_full and never the non-partitioned or LIST table. At windows_ahead 1 it returned 0, because today is already covered everywhere.events_default went from 4 children to 9 and events_strict from 2 to 7, metrics_full stayed at 7 and the LIST table was untouched. An insert for a previously uncovered day then landed in its own new child rather than in DEFAULT or an error, confirmed with the row's tableoid.A PostgreSQL server reachable over JDBC with one or more RANGE partitioned tables keyed on a date or timestamp column. The connecting user must be able to read the catalog and to create partitions on the parent tables.
POSTGRES_USERNAME: PostgreSQL user, read when use_secret_auth is true.POSTGRES_PASSWORD: password for that user.SLACK_WEBHOOK_URL: used by findings_alert and the errors block.SECRET_.| Name | Type | Default | Description |
|---|---|---|---|
postgres_url |
STRING | jdbc:postgresql://localhost:5432/postgres |
PostgreSQL JDBC URL for the target database. |
use_secret_auth |
BOOL | true |
Read credentials from secrets. Set false only for inline test credentials. |
schema |
STRING | "" |
Optional single schema filter. Empty scans every user schema. |
window_size |
SELECT | day |
Partition window size: day, week or month. Match how the tables are partitioned. |
windows_ahead |
INT | 7 |
How many future windows to keep provisioned, counted from the current window. |
dry_run |
BOOL | true |
Report without creating anything. |
auto_remediate |
BOOL | false |
Create behind the approval gate when dry_run is false. |
POSTGRES_USERNAME, POSTGRES_PASSWORD and SLACK_WEBHOOK_URL as namespace secrets.postgres_url pointed at a database that has RANGE partitioned tables. The default dry run reports the missing windows.dry_run false and auto_remediate true, then resume the paused execution with approved true.window_size to week or month to match a weekly or monthly partitioned table.windows_ahead to keep a longer runway of future partitions ready.schema to restrict the sweep to one schema on a large database.