Repository navigation
Resolve an omitted datastore:// namespace to the backend default - #469
Conversation
The namespace in a datastore:// ref is a per-deployment config value (`actionbase.hbase.namespace`), but acquisition passed the URI's namespace straight through, so the migrate CLI had to bake a concrete namespace into every ref and pin the metadata to one environment. Adopt Hadoop's `fs.defaultFS` model: an omitted namespace (`datastore:///<table>`) resolves to the backend's configured default at acquisition. `StorageBackend` now carries a `defaultNamespace`; `HBaseStorageBackend` supplies the namespace it previously only validated, and memory/mock backends supply "default". The `DefaultHBaseCluster` resolution path fills an empty namespace the same way. `STORAGE_URI_PATTERN` accepts the omitted form, and the migrate rewrite emits it. An explicit namespace still resolves as before, so existing refs are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The data-table resolution path (DatastoreIndexedLabel, DatastoreHashOnlyIndexedLabel) parsed datastore:// URIs with a private copy of the split-and-require logic instead of DatastoreUri.parse, so the scheme's rules lived in two places. Delegate to DatastoreUri.parse and keep only the empty-namespace substitution here, leaving one parser for the whole scheme. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Allowing an omitted namespace meant relaxing STORAGE_URI_PATTERN, which previously required a leading letter and so happened to block the reserved `__sys__` namespace. Segments now accept a single leading underscore, but a `__` prefix is reserved: user-supplied storage refs reject it, so a table can't be pointed at `datastore://__sys__/metastore` and bind to the metastore. The internal DatastoreUri parser still accepts `__` names the engine mints. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The rewrite omits the source namespace so refs resolve to the target deployment's configured namespace. That is silent information loss: a table that lived in a non-default namespace gets repointed. `migrate plan` now lists the source namespaces it saw and warns when more than one appears, so the operator can verify before applying. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The storage URI pattern accepted any lowercase alphanumeric/underscore segment and reserved system names by a __ prefix. Every other name in the API starts with a lowercase letter (Constants.Name.PATTERN), so the storage segment was the lone exception, and a __ prefix admits half-delimited names like __sys that belong to neither the user nor the engine. Segments now start with a lowercase letter. That reserves the fully delimited __x__ form for system namespaces without a negative lookahead: the engine still mints datastore://__sys__/metastore through the parser, and no user input can express it. This drops datastore:///_expire. Nothing mints a ref like that - the per-entity top-k work uses topk_expire_* and <name>__expire - and a table or queue named _expire was never creatable, since those fields already validate against Constants.Name.PATTERN. Amends the naming decision in #468. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
requireNotNull let a blank namespace through. It used to be discarded, but it is now the value an omitted-namespace ref resolves to, and TableName.valueOf turns an empty namespace into HBase's own default - so a blank config value would have quietly placed every such ref in the wrong namespace. The resolution itself was only covered on MemoryStorageBackend. Both paths that run in production now have a test: HBaseStorageBackend.create carries the configured namespace as its default, and DefaultHBaseCluster substitutes its own for an omitted namespace while leaving an explicit one alone. parseDatastoreUri becomes internal for that, following resolveKerberosRealm in the same class. The two backends that serve one unnamed space now share StorageBackend.DEFAULT_NAMESPACE instead of repeating the literal. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
storageToDatastoreURI only checked that conf.tableName was present. Legacy HBASE storage entities were never held to the name rule, so a name like Edges became datastore:///Edges and failed with a 400 partway through apply, after earlier entries had already been replayed. The plan phase now rejects it, alongside the storages that have no URI at all. The dropped-namespace note also counted storages no label references, which could warn about multiple source namespaces when every rewritten ref pointed at one. It now counts only the storages a planned label actually references. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Two notes for review. The naming rules in #468 changed while I was finishing this. Segments now start with a lowercase letter like every other name in the API, and the reserved form is the fully delimited One thing I left alone. |
|
Optimistic |
Summary
The namespace in a
datastore://ref is a per-deployment config value (actionbase.hbase.namespace→ab_local,ab_prod), but acquisition passed the URI's namespace straight toTableName.valueOf. So the migrate CLI baked a concrete namespace into every rewritten ref and pinned the metadata to one environment, and thedefaultNamespacethe factory already captured was never read.This implements the
datastore://scheme decision from #468: adopt Hadoop'sfs.defaultFSmodel, where an omitted namespace (datastore:///<table>) resolves to the backend's configured default at acquisition. An explicit namespace still resolves exactly as before, so existing refs are untouched.I amended the naming rules in #468 while writing this. Segments start with a lowercase letter like every other name, and the reserved form is the fully delimited
__x__.Closes #468
Changes
StorageBackendcarries adefaultNamespace;getStorageTable(uri)substitutes it for an empty parsed namespace.HBaseStorageBackendsupplies the namespace it previously onlyrequireNotNulld, and now rejects a blank one — blank would leave an omitted-namespace ref resolving to HBase's owndefaultrather than the deployment's. Backends that serve one unnamed space shareStorageBackend.DEFAULT_NAMESPACE.DefaultHBaseClusterfills an empty namespace with its configured namespace on the data-table resolution path. Its parsing now delegates toDatastoreUri.parse— the data-table path had a private copy of the split-and-require logic, so the scheme's rules now live in one parser.STORAGE_URI_PATTERNaccepts the omitted form (datastore:///<table>) and holds each segment to the letter-start rule, which leaves the reserved__x__form out of reach of user input so it can't targetdatastore://__sys__/metastore.migrate planreports the source namespaces it drops — counting only the storages a planned label references — and rejects aconf.tableNamethe scheme disallows, since legacy storage entities were never held to the name rule.DefaultHBaseCluster, a blank namespace rejected atcreate, the pattern's accept/reject set (including the__x__reservation and the letter-start rule), and the migrate URI shape.One behavior change rides along.
DefaultHBaseCluster.getTable(uri)validated nothing before, so a ref with characters the scheme disallows reachedTableName.valueOf; it now fails at resolution. Nothing creatable through DDL is affected, and the migrate rewrite rejects such a name in the plan phase rather than emitting it.How to Test
AI Assistance