Apache Pulsar multi-tenant backlog quarantine and priority event router
Drain a multi-tenant Pulsar topic and route each batch by tenant priority tier, logging ENTERPRISE traffic and quarantining the rest, with a Slack report per run.
Find Oracle indexes and index partitions left UNUSABLE after a MOVE or direct-path load, rebuild them behind a dry-run gate, then re-check the dictionary.
An Oracle index can be marked UNUSABLE without any error at the time. Move a table or a partition. Split a partition. Run a direct-path load with SKIP_INDEX_MAINTENANCE. Any of these leaves the affected index or index partition STATUS='UNUSABLE'. The optimizer then ignores it, queries fall back to full scans and a unique index stops enforcing its constraint, all silently until someone reads the data dictionary.
This blueprint finds those segments before a query planner does. It reads dba_indexes and dba_ind_partitions for the schemas you name, rebuilds each unusable index with ALTER INDEX REBUILD and each unusable partition with REBUILD PARTITION, then reads the dictionary again and fails the run if anything is still UNUSABLE.
This blueprint was created by zkasuran.
| Where the status lives | Column read | Rebuild used |
|---|---|---|
| Whole index (non-partitioned or global) | dba_indexes.status = 'UNUSABLE' |
ALTER INDEX "owner"."name" REBUILD |
| One index partition (local or global partitioned) | dba_ind_partitions.status = 'UNUSABLE' |
ALTER INDEX "owner"."name" REBUILD PARTITION "p" |
A partitioned index carries dba_indexes.status = 'N/A' and keeps the real state per
partition, so the index level and the partition level are read separately and the two
result sets are unioned. ONLINE is appended to every rebuild by default so base-table
DML is not blocked while the index is rebuilt.
audit (io.kestra.plugin.jdbc.oracle.Query, read-only) reads dba_indexes for
whole indexes whose status is UNUSABLE and dba_ind_partitions for index partitions
whose status is UNUSABLE, limited to the owners in index_owners. It returns the
exact ALTER INDEX REBUILD for each.fixes (io.kestra.plugin.core.output.OutputValues) deduplicates those statements.
summary (io.kestra.plugin.core.log.Log) logs the unusable segments.route (io.kestra.plugin.core.flow.If):alert posts the list to Slack.remediate_gate runs only when auto_remediate is true and dry_run is false.rebuild (io.kestra.plugin.core.flow.Loop, concurrencyLimit: 1) runs each
ALTER INDEX REBUILD in turn, appending ONLINE when rebuild_online is true.reaudit reads the dictionary again. verify_result fails the run through
rebuild_failed if any segment is still UNUSABLE, otherwise rebuilt logs the
before and after counts.errors posts to Slack if the flow fails for any reason, including an index that
could not be rebuilt.The usual fix is a one-off ALTER INDEX a DBA runs by hand after noticing a slow query.
Kestra runs the check on a schedule, scopes it to the schemas you own, posts the unusable
indexes to Slack, applies the rebuild only behind auto_remediate and dry_run, one
segment at a time, then proves the result by reading the dictionary again. Every run
keeps its logs, so you can see when an index went unusable and what rebuilt it.
On Kestra 2.0.5 OSS against Oracle Database Free 23ai (gvenzl/oracle-free, service
FREEPDB1), with a local HTTP sink standing in for Slack. The test schema APP held a
non-partitioned table T1 with a secondary index IDX_T1_C1 plus its primary-key index.
A range-partitioned table TP carried a local index IDX_TP_C1. ALTER TABLE APP.T1 MOVE
and ALTER TABLE APP.TP MOVE PARTITION P1 left two whole indexes and one index partition
STATUS='UNUSABLE', read back from dba_indexes and dba_ind_partitions with sqlplus.
| Run | Inputs | Result |
|---|---|---|
| Clean | defaults, nothing broken | 0 unusable segments, clean branch, SUCCESS |
| Detect | defaults (dry_run: true) |
3 unusable segments found (IDX_T1_C1, IDX_TP_C1 PARTITION P1, the PK index), Slack alert posted, no change. The dictionary still showed 3 |
| Gate hold | auto_remediate: true, dry_run: true |
Same report, Slack said no change applied, the dictionary still showed 3. The dry-run gate held |
| Remediate | auto_remediate: true, dry_run: false |
Rebuilt all 3 with ONLINE, the re-audit returned 0, SUCCESS. The dictionary went from 3 unusable to 0, every segment VALID or USABLE |
| Offline | auto_remediate: true, dry_run: false, rebuild_online: false |
Same 3 rebuilt without ONLINE, re-audit 0, SUCCESS |
| Failure | unreachable instance | audit failed with ORA-17868, the errors block posted to Slack, HTTP 200 |
The clean and detect runs are the proof the check can fail: the same audit returned 0
against the healthy schema and 3 against the broken one. The remediate run is the before
and after, 3 down to 0, read from the dictionary by sqlplus not only from the Kestra log.
The partitioned index is why the index level and the partition level are read separately:
dba_indexes reported IDX_TP_C1 as N/A while dba_ind_partitions carried the real
UNUSABLE on partition P1.
jdbc:oracle:thin:@//host:1521/service).dba_indexes and dba_ind_partitions
(SELECT_CATALOG_ROLE or SELECT ANY DICTIONARY) and rebuild the indexes it finds.
Rebuilding another schema's index needs ALTER ANY INDEX, which a DBA role carries. A
user rebuilding only its own indexes needs none of those.ORACLE_PASSWORD: the database password. It is the default of the password input, so
it is never written in the flow.SLACK_WEBHOOK_URL: used by alert and the errors block.SECRET_.| Input | Default | Purpose |
|---|---|---|
jdbc_url |
jdbc:oracle:thin:@//oracle-host:1521/FREEPDB1 |
The Oracle instance to check |
username |
SYSTEM |
The database user |
password |
{{ secret('ORACLE_PASSWORD') }} |
The database password |
index_owners |
[APP] |
Schema owners whose indexes are checked |
rebuild_online |
true |
Append ONLINE to each REBUILD |
auto_remediate |
false |
Allow ALTER INDEX REBUILD |
dry_run |
true |
Must be false for a rebuild to run |
ORACLE_PASSWORD and SLACK_WEBHOOK_URL secrets.jdbc_url and username, then list the schemas to check in index_owners.auto_remediate: true and dry_run: false.daily trigger, which always runs in safe mode.dba_ind_subpartitions in a third union branch to cover composite-partitioned
indexes, whose status lives one level deeper.rebuild_online: false where an offline rebuild is acceptable and faster during a
maintenance window.