Skip to content

feat(iceberg): log warning when available_parallelism falls back to default#2520

Merged
blackmwk merged 1 commit into
apache:mainfrom
huan233usc:fix/log-available-parallelism-fallback
May 28, 2026
Merged

feat(iceberg): log warning when available_parallelism falls back to default#2520
blackmwk merged 1 commit into
apache:mainfrom
huan233usc:fix/log-available-parallelism-fallback

Conversation

@huan233usc
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Resolves the in-code TODO at crates/iceberg/src/util/mod.rs:40 (no tracking issue).

What changes are included in this PR?

When std::thread::available_parallelism() fails, available_parallelism() falls back to DEFAULT_PARALLELISM (= 1). Both call sites — TableScanBuilder::new and ArrowReaderBuilder::new — use this value to size their internal concurrency, so a silent fallback turns parallel execution into serial with no signal to the operator.

This PR emits a tracing::warn! carrying the underlying error so the degraded state is observable, e.g.:

WARN error=...: Failed to determine available parallelism; falling back to 1

The iceberg crate gains a direct tracing dependency. tracing is already declared at the workspace level and is the agreed logging facade (per the conclusion of #482).

Are these changes tested?

No new unit test. std::thread::available_parallelism() succeeds on every standard CI environment and cannot be forced to fail without mocking the standard library, so a fallback-path test would require either:

  • a cfg(test) indirection layer to inject a mock available_parallelism(), or
  • a custom runner inside a cgroup that artificially constrains parallelism.

Both seemed disproportionate for a one-line observability change. Existing callers (TableScanBuilder, ArrowReaderBuilder) continue to receive a valid NonZeroUsize on success, exercised by the existing test suite. Happy to add either approach if reviewers prefer.

Verified locally:

  • cargo check -p iceberg
  • cargo test -p iceberg --lib util::
  • cargo clippy -p iceberg --all-targets -- -D warnings
  • cargo fmt -p iceberg --check

…efault

When `std::thread::available_parallelism()` fails, `available_parallelism()`
silently falls back to `DEFAULT_PARALLELISM` (= 1). Both call sites
(`TableScanBuilder::new`, `ArrowReaderBuilder::new`) use this value to size
their internal concurrency, so a silent fallback turns parallel execution
into serial with no signal to the operator.

Emit a `tracing::warn!` carrying the underlying error so the degraded state
is observable. Resolves the existing `TODO` in `util::available_parallelism`.

The `iceberg` crate gains a direct `tracing` dependency; `tracing` is
already declared at the workspace level and is the agreed logging facade
(see apache#482).
Copy link
Copy Markdown
Contributor

@blackmwk blackmwk left a comment

Choose a reason for hiding this comment

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

Thanks @huan233usc for this pr!

@blackmwk blackmwk merged commit 47527fe into apache:main May 28, 2026
22 checks passed
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.

2 participants