Skip to content

fix: [branch-1.2] apply the session's Comet configs in map stages of jobs outside a SQL execution (#7302) - #7337

Merged
andygrove merged 4 commits into
apache:branch-1.2from
andygrove:backport-7302-branch-1.2
Oct 30, 2026
Merged

andygrove merged 4 commits into
apache:branch-1.2from
andygrove:backport-7302-branch-1.2

Conversation

@andygrove

Copy link
Copy Markdown
Member

Which issue does this PR close?

Backport of #7302 to branch-1.2. #7302 closes #7301 on main.

Rationale for this change

A job launched from a query's RDD (Dataset.rdd with AQE off, QueryExecution.toRdd) runs its map stages outside a SQL execution, so on an executor those stages ran with every spark.comet.* setting at its default (memory pool, batch size, the configs passed to native), with no warning (#7301, bug). branch-1.2 has this bug, so it needs the fix before 1.2.0 ships.

branch-1.2 is the newest release branch, so no newer branch needs a backport. #7302 carries only the backport-1.2 label, so no branch-1.1 backport is part of this.

What changes are included in this PR?

git cherry-pick -x 15305af627 of the squash commit of #7302. One conflict, in the import block of CometNativeShuffleSuite.scala: branch-1.2 already lacks the RangePartitioning import that main still has, so the resolution keeps branch-1.2's HashPartitioning import and takes #7302's added CometCollectLimitExec import. The added and removed lines are otherwise identical to the source commit. See #7302 for the full description.

How are these changes tested?

On this branch, with a libcomet built from the pick (the fix is JVM-only):

  • ./mvnw test-compile passes on the default profile (Spark 4.1) and on -Pspark-3.5.
  • CometNativeShuffleSuite, CometJoinSuite, CometTaskMetricsSuite, NativeUtilSuite and CometNativeShuffleInputRDDSuite pass: 235 succeeded, 0 failed. That includes the five new ... outside a SQL execution uses the session's Comet configs tests.

I did not re-run the new tests without the fix on this branch (#7302 shows them failing before the change), and I did not run the Spark SQL test suites that #7302's CI ran.

…a SQL execution (apache#7302)

* fix: apply the session's Comet configs in map stages of jobs outside a SQL execution

On an executor, SQLConf.get reads the task's local properties, which
Spark fills with the session's configs only for jobs that run inside a
SQL execution. A job launched from a query's RDD (Dataset.rdd with AQE
off, QueryExecution.toRdd) runs its map stages outside one, and Spark's
SQLExecutionRDD re-applies the session's configs only in the final
stage. Comet reads its settings on the executor when it builds a native
plan, so those map stages ran with every spark.comet.* setting at its
default, including the memory pool and the configs passed to native.

Capture the session's configs on the driver where Comet builds the RDDs
and native shuffle that run native plans, and make them what SQLConf.get
returns on the task thread while the plan is built, as SQLExecutionRDD
does. Tasks inside a SQL execution are unchanged.

Closes apache#7301.

* refactor: capture only Comet configs once per shuffle and let configs Spark passed win

Capture only spark.comet.* keys, and apply them only when no conf is set
on the thread and the task got none of the session's Comet configs from
Spark, so SQLExecution.withSQLConfPropagated still takes effect. Carry
the native shuffle's one captured conf from its input RDD to the writer,
apply it inside the serialized-plan getCometIterator, and drop the test
workarounds this change makes redundant.

* fix: apply the session's Comet configs to shuffle reads and test each native plan site

A Comet shuffle read with no native plan above it in its stage, such as
one feeding a Spark operator in an intermediate stage, still read Comet
defaults. Capture the configs in CometShuffledBatchRDD and apply them in
compute and computeAsShuffleBlockIterator, which makes the wrap in
CometNativeShuffleInputRDD.compute redundant, so drop it. Make that RDD's
sqlConf required so each call site captures on the driver explicitly.

Replace the single test with one per site: the native shuffle writer, a
native plan in a map stage, the native limit, the native top-K, each
checking the memory pool every native plan resolves, and a shuffle read
under spark.comet.shuffle.readBufferSize=0.

* fix: apply the captured configs to the Celeborn frame size and capture DEBUG logs in tests

The native Celeborn writer read spark.comet.shuffle.rss.maxFrameBytes in
getWriter, before the writer applies the captured configs. Carry the
configs on NativeShuffleSpec, which getWriter can reach through the
dependency, and apply them to that read as well as in the writer, in
place of CometNativeShuffleInputRDD and its iterator.

Spark's LogAppender keeps INFO and above by default, so set its threshold
to DEBUG for the memory pool line the tests read.

---------

Co-authored-by: Andy Grove <[email protected]>
(cherry picked from commit 15305af)
@github-actions github-actions Bot added bug Something isn't working area:shuffle Shuffle (JVM and native) labels Oct 30, 2026
GitHub retires the macos-14 runner image on November 2, 2026 and is
already cancelling jobs on it during scheduled brownouts.

(cherry picked from commit 2d168e8)

@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 @andygrove

@andygrove
andygrove merged commit 828af43 into apache:branch-1.2 Oct 30, 2026
139 checks passed
@andygrove
andygrove deleted the backport-7302-branch-1.2 branch October 30, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:shuffle Shuffle (JVM and native) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants