Skip to content

fix: isolate object-store registration by backend and configuration - #5503

Open
sunchao wants to merge 1 commit into
apache:mainfrom
sunchao:dev/chao/codex/comet-isolation-followup
Open

fix: isolate object-store registration by backend and configuration#5503
sunchao wants to merge 1 commit into
apache:mainfrom
sunchao:dev/chao/codex/comet-isolation-followup

Conversation

@sunchao

@sunchao sunchao commented Aug 27, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #5502.

Rationale for this change

A configuration can route s3 through Hadoop while leaving s3a on the native backend. Normalizing native s3a to s3 currently gives those different backends the same process-cache key. Separately, DataFusion's registry identifies stores by scheme and authority, so registering a second configuration can overwrite the first mapping.

This extracts the object-store correctness change from #5453. It contains no new scan counters or producer-lifecycle changes and does not depend on that metrics PR.

What changes are included in this PR?

Include backend identity in the cache key and register each non-local backend/configuration under a deterministic internal URL. The first registration receives the same identity it would receive after another store, so planning order cannot affect routing. Native s3 and s3a share canonical s3 identity; Hadoop-selected schemes retain their physical spelling. Native local files keep file:// behavior.

Reconstruct the physical URI before configuring encryption lookup, stripping only a complete internal identity suffix. This preserves existing s3/s3a key normalization and custom Hadoop schemes. The change isolates object-store lookup, not file-metadata caches.

How are these changes tested?

The focused tests use two distinct in-memory stores and verify actual returned bytes after registration in both orders. Cases cover a normalized S3 alias/backend collision, different native configurations, custom Hadoop routing, native S3 alias reuse, and native versus Hadoop-routed file URLs. Encryption-option tests compare ordinary and isolated physical URIs, including aliases, ports, custom schemes, and local files.

The full native crate compiled with the two disjoint extracted changes combined at their shared base. All 90 Parquet tests passed, including the six new isolation/encryption regressions, with a confirmed zero process exit status. The four companion producer-lifecycle tests also passed. cargo fmt --all --check and git diff --check pass. Default native features and JDK 21 were used; tests use deterministic in-memory stores rather than a live Hadoop/cloud deployment. Full Spark integration and this branch's hosted CI have not run locally.

@comphead

Copy link
Copy Markdown
Contributor

would be related to #5314

// Registration URLs use a reserved suffix to distinguish backend/configuration
// identities. Encryption must use the physical URI that Spark registered. Match
// the complete suffix, from the right, so custom Hadoop schemes are preserved.
fn physical_object_store_scheme(object_store_url: &ObjectStoreUrl) -> &str {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we already have a similar method is_hdfs_scheme maybe its time to unify them

}

type ObjectStoreCache = RwLock<HashMap<(String, u64), Arc<dyn ObjectStore>>>;
type ObjectStoreCacheKey = (String, u64, bool);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document what is (String, u64, bool) represents

} else {
let backend = if is_hdfs_scheme { "hdfs" } else { "native" };
ObjectStoreUrl::parse(format!(
"{scheme}+comet-{config_hash:016x}-{backend}://{}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would comet be a hardcoded part of url?

@comphead comphead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sunchao makes sense to me, some small nits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid object-store cache and registry collisions across backends and configurations

2 participants