Skip to content

[SPARK-55619][SQL][4.1] Fix custom metrics in case of coalesced partitions - #54407

Closed
viirya wants to merge 1 commit into
apache:branch-4.1from
viirya:SPARK-55619-branch-4.1
Closed

[SPARK-55619][SQL][4.1] Fix custom metrics in case of coalesced partitions#54407
viirya wants to merge 1 commit into
apache:branch-4.1from
viirya:SPARK-55619-branch-4.1

Conversation

@viirya

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Replace PartitionMetricCallback with a ConcurrentHashMap keyed by task attempt ID to correctly track reader state across multiple compute() calls when DataSourceRDD is coalesced. The completion listener is registered only once per task attempt, and metrics are flushed and carried forward between readers as partitions are advanced.

Why are the changes needed?

When DataSourceRDD is coalesced (e.g., via .coalesce(1)), compute() gets called multiple times per task, which causes the custom metrics incorrect.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Unit test

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Sonnet 4.6

@viirya

Copy link
Copy Markdown
MemberAuthor

@dongjoon-hyundongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, LGTM (Pending CIs)

@dongjoon-hyun

Copy link
Copy Markdown
Member

Could you re-trigger the failed test pipeline?

@viirya

Copy link
Copy Markdown
MemberAuthor

Could you re-trigger the failed test pipeline?

Re-triggered it but failed again. Re-triggered now.

@viirya
viiryaforce-pushed the SPARK-55619-branch-4.1 branch 2 times, most recently from 22ea03f to 84809b7CompareFebruary 21, 2026 18:43
…tions
Replace PartitionMetricCallback with a ConcurrentHashMap keyed by task
attempt ID to correctly track reader state across multiple compute()
calls when DataSourceRDD is coalesced. The completion listener is
registered only once per task attempt, and metrics are flushed and
carried forward between readers as partitions are advanced.
Co-Authored-By: Peter Toth <peter.toth@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@viirya
viiryaforce-pushed the SPARK-55619-branch-4.1 branch from 84809b7 to 5425638CompareFebruary 21, 2026 21:35
viirya added a commit that referenced this pull request Feb 22, 2026
…tions
### What changes were proposed in this pull request?
Replace `PartitionMetricCallback` with a `ConcurrentHashMap` keyed by task attempt ID to correctly track reader state across multiple `compute()` calls when `DataSourceRDD` is coalesced. The completion listener is registered only once per task attempt, and metrics are flushed and carried forward between readers as partitions are advanced.
### Why are the changes needed?
When `DataSourceRDD` is coalesced (e.g., via `.coalesce(1)`), `compute()` gets called multiple times per task, which causes the custom metrics incorrect.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Unit test
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Sonnet 4.6
Closes#54407 from viirya/SPARK-55619-branch-4.1.
Authored-by: Liang-Chi Hsieh <viirya@gmail.com>
Signed-off-by: Liang-Chi Hsieh <viirya@gmail.com>
@viiryaviirya closed this Feb 22, 2026
@viirya
viirya deleted the SPARK-55619-branch-4.1 branch February 22, 2026 00:27
@viirya

Copy link
Copy Markdown
MemberAuthor

Sign up for freeto 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.

4 participants

@viirya@dongjoon-hyun@peter-toth@szehon-ho