bug: InMemoryCatalog skips the namespace existence check in CreateTable and RegisterTable
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 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 天 11 小時
- 30 天內合併 PR
- 27
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
apache/iceberg-cpp 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
apache/iceberg-cpp#978 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
apache/iceberg-cpp#973 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 75/100
apache/iceberg-cpp#979 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 20/100
apache/iceberg-cpp#959 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 45/100
apache/iceberg-cpp#955 · 3 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
查看 apache/iceberg-cpp 的全部 Issue
相似的 Issue
-
area/ysql kind/bug priority/medium
難度 2/5 1-3 小時 新手友好度 75/100
yugabyte/yugabyte-db#34552 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 86/100
維護者通常 1 天內回覆
-
bug
難度 1/5 1 小時以內 新手友好度 94/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
ai_p2
難度 2/5 1-3 小時 新手友好度 76/100
ClickHouse/ClickHouse#123351 ·
維護者通常 1 天內回覆