bug: InMemoryCatalog skips the namespace existence check in CreateTable and RegisterTable
Maintainer antworten meist innerhalb von 2 Tagen
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 78/100
Rechercherichtung
Beginne in src/iceberg/catalog/memory/in_memory_catalog.cc und untersuche CreateTable und RegisterTable. Vergleiche anschließend die Behandlung von Namespaces mit SqlCatalog::CreateTable. Als erledigt gilt die Änderung, wenn fehlende Namespaces vor dem Schreiben der Metadaten als kNoSuchNamespace abgelehnt werden, ohne das nicht zum Umfang gehörende Verhalten bei doppelten Registrierungen zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- C++
- Sterne
- 226
- Forks
- 133
- Ø Merge
- 5 T. 20 Std.
- Gemergte PRs (30 T.)
- 39
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus apache/iceberg-cpp
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
apache/iceberg-cpp#1000 · 2 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Support Iceberg table encryption (Java-compatible)Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 8/100
apache/iceberg-cpp#988 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
apache/iceberg-cpp#959 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
apache/iceberg-cpp#946 · 5 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
apache/iceberg-cpp#944 ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in apache/iceberg-cpp
Ähnliche Issues
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
leanprover/lean4#15683 ·
Maintainer antworten meist innerhalb von 1 Tag
-
llvm.memcpy with destination align but no source align asserts "Missed Source alignment!"Evtl. vergeben @pvelesko hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
KhronosGroup/SPIRV-LLVM-Translator#4093 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 1 Tag
-
SIMQ silently truncates multi-query batch search to the first queryEvtl. vergeben @LHT129 hat das heute übernommen. Offenkind/bug module/index needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
antgroup/vsag#3080 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag