Detect Qdrant embedding drift and verify bounded re-embedding
Compare live embeddings with stored vectors and repair an approved batch only when held-out retrieval has degraded.
Find published PostgreSQL tables with no replica identity, which reject UPDATE and DELETE, alert Slack, set USING INDEX or FULL and verify.
Adding a table to a logical replication publication, for CDC with Debezium, a read replica or a migration, has a sharp edge. If the publication publishes updates or deletes and the table has no primary key, every UPDATE and DELETE on it starts failing. PostgreSQL raises cannot update table because it does not have a replica identity and publishes updates. It is the application that breaks, not the replication, and usually right after someone ran CREATE PUBLICATION ... FOR ALL TABLES.
This blueprint finds the published tables that are in that state, or about to be. It alerts Slack, and can set the right replica identity:
USING INDEX on a unique index whose columns are all NOT NULL, when one exists;FULL otherwise.A second audit verifies the result.
This blueprint was created by zkasuran.
| Finding | Severity | Rule | Fix |
|---|---|---|---|
NO_REPLICA_IDENTITY |
High | In a publication that publishes UPDATE or DELETE, with no primary key and identity DEFAULT, or identity NOTHING |
REPLICA IDENTITY USING INDEX on the best unique not-null index, else FULL (if allow_full) |
FULL_WITH_KEY |
Medium | Identity FULL, although a unique not-null index exists |
Report only: USING INDEX would write much less WAL |
Tables in insert-only publications are never flagged: they are not affected.
audit (io.kestra.plugin.jdbc.postgresql.Query, read-only) joins pg_publication, pg_publication_tables and pg_class, and looks for a candidate index:
NOT NULL.It returns each finding with its fix, built with regclass and format('%I').
summary logs every finding with its publications, current identity and row count.
route (io.kestra.plugin.core.flow.If):
alert posts to Slack.remediate_gate runs only when auto_remediate is true and dry_run is false.remediate (io.kestra.plugin.core.flow.Loop) runs each ALTER TABLE ... REPLICA IDENTITY in its own task.reaudit and verify_result fail if a fixed table still has no replica identity.errors alerts Slack when the audit cannot run.
FULL only as a fallback.FULL when they do not need to.ALTER TABLE.The failure shows up as application errors, not as a replication alert. Kestra checks the publications every hour or after each schema change, and turns findings into a Slack alert naming the tables and publications. It applies the fix only behind auto_remediate and dry_run, verifies it, and keeps a history of every identity change.
On Kestra 2.0.5 OSS against PostgreSQL 16, with a local HTTP sink standing in for Slack. The publication cdc_pub holds:
cdc_events (50,000 rows, no key at all);cdc_tags (20,000 rows, no primary key but a unique index on two NOT NULL columns);cdc_users (primary key);cdc_ledger (FULL, with a unique not-null index).An insert-only publication holds cdc_audit, with no key.
Before the fix, UPDATE cdc_events and DELETE FROM cdc_tags failed with the replica identity error.
| Run | Inputs | Result |
|---|---|---|
| 1 | defaults | 2 high findings: cdc_events with fix FULL, cdc_tags with fix USING INDEX cdc_tags_uq. cdc_ledger medium. cdc_users and cdc_audit not flagged. Alert sent |
| 2 | auto_remediate: true, dry_run: true |
Same report, nothing changed |
| 3 | auto_remediate: true, dry_run: false |
Both fixes applied and verified. pg_class.relreplident shows f and i, and the same UPDATE and DELETE now succeed |
| 4 | defaults | Only the FULL_WITH_KEY report left |
| 5 | cdc_ledger switched to USING INDEX by hand |
Clean |
| 6 | unreachable database | errors alert sent |
ALTER TABLE ... REPLICA IDENTITY takes a brief lock.docker run -d --name pg -p 5432:5432 -e POSTGRES_PASSWORD=pg postgres:16;CREATE PUBLICATION p FOR TABLE t and try an UPDATE.POSTGRES_USERNAME / POSTGRES_PASSWORD: credentials used by every query.SLACK_WEBHOOK_URL: used by alert and the errors block.SECRET_.| Input | Default | Purpose |
|---|---|---|
jdbc_url |
jdbc:postgresql://localhost:5432/app |
Database |
allow_full |
true |
Use FULL when no index fits |
auto_remediate |
false |
Allow ALTER TABLE |
dry_run |
true |
Must be false for a statement to run |
POSTGRES_USERNAME, POSTGRES_PASSWORD and SLACK_WEBHOOK_URL secrets.jdbc_url.auto_remediate: true and dry_run: false.hourly trigger, which always runs in safe mode, or call the flow after each migration.ALTER PUBLICATION ... ADD TABLE in your migration pipeline, and stop the pipeline on a finding.FULL when a column is unique in practice, after a duplicate check.FULL tables from pg_stat_replication_slots.