Queries icon
OutputValues icon
Log icon
If icon
SlackIncomingWebhook icon
Pause icon
Fail icon
Loop icon
Execute icon
Sleep icon
Query icon
Schedule icon

ScyllaDB Unused Secondary Index Drop Guard

Detect ScyllaDB secondary indexes with zero reads, capture their definitions and safely drop approved indexes with verification.

Categories
Data

An abandoned secondary index is a write tax: ScyllaDB maintains the index backing table for every base-table write even when the query that justified it is gone. The cost is easy to miss because the base table still accepts writes and the index catalog still looks healthy.

Safety

The target set is bounded by target_keyspaces and the optional fully qualified target_indexes allow-list. protected_indexes is a second explicit spare list for low-traffic indexes that are still intentional. The audit reads system_schema.indexes and system.sstable_activity, retaining each index's kind and complete options map plus the generated recreation statement. An index is a candidate only when both the 15-minute and 120-minute backing-table read rates are exactly zero. A missing activity row is treated as zero and is shown in the report.

A write requires auto_remediate: true, dry_run: false and a human approval. After that approval the flow reads the catalog and activity rates again. If an approved name disappeared, became active or is protected, the run fails before any DROP INDEX. Drops run serially with concurrencyLimit: 1; the final catalog read fails the run if a requested index remains. This verifies schema removal and keeps the captured definition available for a deliberate recreation. It does not infer latency or cost savings from CQL metadata.

How it works

  1. catalog_and_activity (io.kestra.plugin.scylladb.Queries) reads system_schema.indexes and system.sstable_activity in one ScyllaDB CQL session. The latter supplies ScyllaDB's own rate_15m and rate_120m values for the index backing table.
  2. assess (io.kestra.plugin.core.output.OutputValues) joins each catalog row to its local backing table, applies the allow-list and protected list and records UNUSED, IN_USE or PROTECTED with the full definition and a DROP INDEX plus recreation statement.
  3. route alerts Slack when candidates exist. The default path only reports exact counters and spared controls.
  4. When both write gates are true, approval (io.kestra.plugin.core.flow.Pause) holds the exact plan. recheck (io.kestra.plugin.scylladb.Queries) repeats both reads after approval. recheck_plan refuses stale or active targets before drop can run.
  5. drop (io.kestra.plugin.core.flow.Loop, concurrencyLimit: 1) calls io.kestra.plugin.scylladb.Execute once per approved CQL statement. verify_catalog (io.kestra.plugin.scylladb.Query) reads the catalog again and verify_result fails if any requested index survives.
  6. The disabled daily Schedule always supplies safe inputs. The errors block alerts Slack when the connection, query, approval or verification fails.

What you get

  • A read-only report of index names, backing-table activity rates, kind, options and exact drop/recreation text.
  • A bounded, serial, approval-gated drop path with an immediate stale-plan check.
  • A post-write catalog proof that the requested indexes are absent, while protected and active controls remain visible.
  • Execution evidence that separates an index removal from an unmeasured latency claim.

Who it's for

  • ScyllaDB platform teams cleaning up indexes left by retired query paths.
  • Operators who need a reversible, reviewable schema change rather than an ad hoc cqlsh command.
  • Teams evaluating the ScyllaDB plugin's Query, Queries and Execute tasks against a real cluster.

Why orchestrate this with Kestra

A one-off DROP INDEX loses the evidence that justified it and can race an application release. Kestra keeps the catalog snapshot, activity counters, approval, stale-plan decision, serial writes and verification in one execution. The disabled schedule gives teams an auditable recurring audit before they choose to arm remediation.

Tested end to end

On Kestra 2.0.5 with the ScyllaDB plugin and an official ScyllaDB container, the fixture creates one unqueried index, one queried index and a protected low-traffic index. cqlsh and nodetool give the independent reads; the execution records the catalog options and activity rates.

Case Result
Protected control The protected index keeps verdict PROTECTED and no write is planned. IN_USE was checked with jq on sample rows only.
Degraded dry run The unqueried index is UNUSED with rate_15m=0 and rate_120m=0; cqlsh confirms all definitions remain.
Declined approval The Pause resumes false; no DROP INDEX runs.
Remediation One approved index is dropped serially; the final system_schema.indexes read finds it absent and the options map stays in outputs.
Repeat A second read-only run reports no candidate for the removed name.
Stale approval A read is issued during the Pause; the fresh activity/catalog read refuses the target before any write.

Prerequisites

  • ScyllaDB reachable from the Kestra Worker, with CQL read access to system_schema.indexes and system.sstable_activity; remediation also needs permission to drop indexes.
  • The ScyllaDB plugin (io.kestra.plugin.scylladb.Query, Queries and Execute).
  • A test fixture with one queried and one unqueried secondary index. Confirm rates independently with nodetool tablestats and definitions with cqlsh before arming remediation.

Secrets

  • SCYLLADB_USERNAME and SCYLLADB_PASSWORD: credentials for the CQL connection.
  • SLACK_WEBHOOK_URL: Slack incoming webhook for findings and flow failures.

Inputs

Input Default Purpose
scylla_host localhost CQL contact point hostname
scylla_port 9042 Native CQL port
local_datacenter datacenter1 Driver local datacenter
target_keyspaces [app] Keyspaces in scope
target_indexes [] Optional fully qualified allow-list
protected_indexes [] Fully qualified names to spare
auto_remediate false Enable approval-gated drops
dry_run true Keep the flow read-only unless false

Quick start

  1. Add the ScyllaDB credentials and SLACK_WEBHOOK_URL to Kestra secrets.
  2. Import the flow and run it with target_keyspaces set to one test keyspace.
  3. Compare the report's rates and options with nodetool tablestats and cqlsh. Add intentional low-traffic names to protected_indexes.
  4. After review, run with auto_remediate: true and dry_run: false, then approve the exact plan.
  5. Keep daily disabled until the read-only report is part of your change process.

How to extend

  • Add a longer observation policy backed by an external persisted counter if a query is legitimately less frequent than 120 minutes.
  • Add a change ticket identifier to the Pause and Slack payload.
  • Pair the guard with a schema backup process that stores the captured options map outside the execution retention period.

Limits: system.sstable_activity reports ScyllaDB's 15-minute and 120-minute rates rather than a durable per-index lifetime counter. A newly created or recently restarted index can therefore look unused. This flow refuses no candidate for that reason; operators should keep new or recently restarted indexes in protected_indexes until the two windows have elapsed. It proves index removal, not a quantified write-latency or storage reduction.

Links

This blueprint was created by zkasuran.

See How

New to Kestra?

Use blueprints to kickstart your first workflows.