bug: InMemoryCatalog skips the namespace existence check in CreateTable and RegisterTable
维护者通常 2 天内回复
评估
调研方向
从 src/iceberg/catalog/memory/in_memory_catalog.cc 开始,检查 CreateTable 和 RegisterTable,然后将 namespace 的处理方式与 SqlCatalog::CreateTable 进行比较。完成的标准是:在写入元数据之前,将缺失的 namespace 拒绝为 kNoSuchNamespace,同时不改变超出范围的重复注册行为。
由索引模型根据 Issue 内容生成。
描述
Summary
InMemoryCatalog fails to validate that a table's namespace exists before acting, in two methods.
CreateTable writes the table metadata file through FileIO before it checks the namespace. Creating a table under a namespace that does not exist returns kNoSuchNamespace, but on an object-store FileIO the call first writes an orphaned 00000-<uuid>.metadata.json that nothing ever removes (DropTable's purge only touches registered tables). On the default local FileIO the stray write fails first, so the caller gets a misleading kIOError instead of kNoSuchNamespace.
RegisterTable guards with if (!root_namespace_->NamespaceExists(identifier.ns)). NamespaceExists returns Result<bool> (std::expected<bool, Error>); !result tests has_value(), not the contained bool, and a missing namespace is reported as a value false, never an error. The guard therefore never fires, so registering under a missing namespace falls through and surfaces as kUnknownError ("The registry failed.") instead of kNoSuchNamespace.
Root Cause
CreateTable (src/iceberg/catalog/memory/in_memory_catalog.cc): the namespace is only enforced inside UpdateTableMetadataLocation, which runs after TableMetadataUtil::Write has already persisted the file. TableExists(identifier).value_or(false) ahead of the write swallows the kNoSuchNamespace from the namespace lookup and reports "table absent", so control falls through to the write.
RegisterTable: if (!root_namespace_->NamespaceExists(identifier.ns)) reads as if (!result.has_value()). NamespaceExists maps a missing namespace to Ok(false), so the branch is dead code; the error later comes out of the inner RegisterTable and is rewritten to kUnknownError.
Impact
CreateTable leaks an orphan metadata file on object-store FileIO and returns the wrong error kind (kIOError) on local FileIO. InMemoryCatalog is documented as not for production use (unit tests, prototyping, demonstration), so this is a correctness and robustness issue, not a security one.
RegisterTable returns kUnknownError for a missing namespace instead of kNoSuchNamespace. SqlCatalog::RegisterTable and the REST error handler both return kNoSuchNamespace, so InMemoryCatalog is the outlier here.
Proposed Fix
Unwrap NamespaceExists and return kNoSuchNamespace before any metadata write, in both methods, mirroring SqlCatalog::CreateTable.
Out of scope
RegisterTablestill maskskAlreadyExistsaskUnknownErroron the duplicate-registration path (if (!root_namespace_->RegisterTable(...))); the clean fix isICEBERG_RETURN_UNEXPECTED(...), asRenameTablealready does. Follow-up.StageCreateTableandUpdateTable's create branch share the same write-before-validate pattern. Follow-up.
- 主要语言
- C++
- 星标
- 226
- 派生
- 132
- 平均合并
- 1 天 18 小时
- 30 天内合并 PR
- 26
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/iceberg-cpp 的其他 Issue
-
bug: ReferenceVisitor::GetReferencedFieldIds dereferences null on a bound COUNT(*)可能已有人在做 @LuciferYang 于 5 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
apache/iceberg-cpp#978 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
apache/iceberg-cpp#973 ·
维护者通常 2 天内回复
-
bug: expression JSON deserialization throws an uncaught exception on a non-string "type"/"term"可能已有人在做 @LuciferYang 于 5 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 75/100
apache/iceberg-cpp#979 ·
维护者通常 2 天内回复
-
难度 5/5 一周以上 新手友好度 20/100
apache/iceberg-cpp#959 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
apache/iceberg-cpp#946 · 5 条评论 ·
维护者通常 2 天内回复
查看 apache/iceberg-cpp 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
shadps4-emu/shadps4-qtlauncher#465 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
Qiskit/qiskit-aer#2466 ·
-
bug needs-triage
难度 2/5 1-3 小时 新手友好度 75/100
NVIDIA/attestation-sdk#41 · 1 条评论 ·
-
[Bug]: CMAKE Fails to find libgit2 on POP OS可能已有人在做 @Tirpitz93 今天认领。 未关闭bug
难度 1/5 1 小时以内 新手友好度 85/100
subsurface/subsurface#5007 · 2 条评论 ·
维护者通常 2 天内回复
-
feature request
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 2 天内回复