Skip to content

HIVE-30080: Queries can get stuck compiling during SharedWorkOptimizer - #6806

Open
kasakrisz wants to merge 2 commits into
apache:masterfrom
kasakrisz:HIVE-30080-master-swo-infinite-loop
Open

kasakrisz wants to merge 2 commits into
apache:masterfrom
kasakrisz:HIVE-30080-master-swo-infinite-loop

Conversation

@kasakrisz

@kasakrisz kasakrisz commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Use a visited set to track operators while traversing the Hive operator plan in SharedWorkOptimizer.findDescendantWorkOperators.

Why are the changes needed?

Hive operator plans cannot cycle if all the edges are represented by a Reduce Sink operator. However, when there are semijoin and/or DPP edges, those can reference back to a Mapper and it may create a cycle.

Map 1 - RS -> Reducer 2          (normal edge)
Reducer 2 -> DPP -> Map 1        (semijoin/DPP back-edge)

This can lead to an infinite loop when traversing the plan.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

mvn test -Dtest.output.overwrite -Dtest=TestMiniLlapLocalCliDriver -Dqfile=sharedwork_dpp_no_map_join.q -pl itests/qtest -Pitests
mvn test -Dtest=TestSharedWorkOptimizer -pl ql

Comment thread ql/src/java/org/apache/hadoop/hive/ql/optimizer/SharedWorkOptimizer.java Outdated
@kasakrisz
kasakrisz force-pushed the HIVE-30080-master-swo-infinite-loop branch from 7f566fe to 401e454 Compare September 24, 2026 09:12
@kasakrisz
kasakrisz requested a review from deniskuzZ September 24, 2026 09:13
@sonarqubecloud

Copy link
Copy Markdown

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

while (!remaining.isEmpty()) {
Operator<?> op = remaining.poll();

if (excludeOps.contains(op)) {

@deniskuzZ deniskuzZ Sep 24, 2026 •

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.

i would collapse 2 blocks into 1, but either ok

if (excludeOps.contains(op) || !visited.add(op)) {
  continue;
}

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants