Skip to content

Reject datastore table teardown while a URI-bound label references it - #477

Merged
em3s merged 1 commit into
mainfrom
fix/guard-datastore-table-references
Aug 6, 2026
Merged

em3s merged 1 commit into
mainfrom
fix/guard-datastore-table-references

Conversation

@em3s

@em3s em3s commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Disabling or dropping an HBase table only checked for a StorageEntity naming it. A label can bind straight to the table with a datastore://{namespace}/{table} URI and no storage entity at all, and every table the v3 API creates takes that form. So a table serving live reads and writes could be disabled or dropped.

Relates to #370

Changes

  • Add DatastoreTableReferences, resolving both binding forms
  • Use it in DatastoreHBaseService and HBaseController, replacing three copies of the inline storage scan
  • Refuse to answer when a metadata scan hits metadataFetchLimit — a truncated page can't prove a table is unreferenced
  • Wrap the admin call in Mono.defer so the guard runs first. An argument to then is evaluated eagerly, which put connection setup ahead of the check

How to Test

./gradlew :engine:test :server:test

Behavior change

Teardown that used to succeed is now rejected — a table bound by an active label has to be deactivated first. /graph/v2/admin/hbase stays cluster-blind as before, so for a remote cluster it errs toward refusing.

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Code (Opus 5)

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Aug 6, 2026
@em3s
em3s force-pushed the fix/guard-datastore-table-references branch 3 times, most recently from d264d3b to 0fbae0f Compare August 6, 2026 08:56
Disabling or dropping an HBase table checked only for a `StorageEntity` naming it. A label can
instead bind straight to the table with a `datastore://{namespace}/{table}` URI and no storage
entity at all, and every table created through the v3 API takes that form —
`TableCreateRequest.storage` is validated against `Constants.Name.STORAGE_URI_PATTERN`. The scan
found nothing for those, so a table serving live reads and writes could be disabled or dropped.

`DatastoreTableReferences` resolves both binding forms against the metadata graph, completing the
`alias -> label -> storage -> table` chain whose upper hops `LabelDdlService.canDeactivate` and
`StorageDdlService.canDeactivate` already guard. It also handles `datastore:///{table}`, which
omits the namespace and resolves to the cluster's configured one.

Both HBase admin surfaces now use it, replacing three copies of the inline storage scan. The v2
copies also dereferenced `conf.get("namespace")` without a null check.

This rejects teardown that used to succeed. A table bound by an active label must now be
deactivated first, which is the order the rest of the chain already enforces.

`/graph/v2/admin/hbase` stays cluster-blind: it matches against this server's metadata whatever
`cluster` the caller names, as it always has. For a remote cluster that errs toward refusing.
@em3s
em3s force-pushed the fix/guard-datastore-table-references branch from 0fbae0f to 4fae82e Compare August 6, 2026 09:05
@em3s

em3s commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Optimistic

@em3s
em3s merged commit 6b24c6c into main Aug 6, 2026
2 checks passed
@em3s
em3s deleted the fix/guard-datastore-table-references branch August 6, 2026 09:09
@em3s em3s self-assigned this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant