Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-21871][SQL] Fix infinite loop when bytecode size is larger than spark.sql.codegen.hugeMethodLimit #19440

Closed
wants to merge 3 commits into from

Conversation

gatorsmile
Copy link
Member

What changes were proposed in this pull request?

When exceeding spark.sql.codegen.hugeMethodLimit, the runtime fallbacks to the Volcano iterator solution. This could cause an infinite loop when FileSourceScanExec can use the columnar batch to read the data. This PR is to fix the issue.

How was this patch tested?

Added a test

@gatorsmile
Copy link
Member Author

cc @maropu @rednaxelafx

@SparkQA
Copy link

SparkQA commented Oct 5, 2017

Test build #82485 has finished for PR 19440 at commit 473bbf0.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

s"`${SQLConf.WHOLESTAGE_HUGE_METHOD_LIMIT.key}`:\n$treeString")
child match {
// For batch file source scan, we should continue executing it
case f: FileSourceScanExec if f.supportsBatch => // do nothing
Copy link
Member

Choose a reason for hiding this comment

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

I feel a little weird WholeStageCodegenExec has specific error handling for each spark plan. Could we handle this error inside FileSourceScanExec? For example, how about checking if parent.isInstanceOf[WholeStageCodegenExec] in FileSourceScanExec?

Copy link
Member Author

Choose a reason for hiding this comment

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

If we do it in FileSourceScanExec , we are unable to know which causes the fallback. Now, we have at least two reasons that trigger the fallback.

Ideally, we should not call WholeStageCodegenExec in doExecute.

Copy link
Member

Choose a reason for hiding this comment

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

yea, I totally agree that we need to refactor this in future. Anyway, it's ok for now.

@maropu
Copy link
Member

maropu commented Oct 6, 2017

Thanks for pining! LGTM except for one comment.


withSQLConf(SQLConf.WHOLESTAGE_MAX_NUM_FIELDS.key -> "202",
SQLConf.WHOLESTAGE_HUGE_METHOD_LIMIT.key -> "8000") {
// donot return batch, because whole stage codegen is disabled for wide table (>202 columns)
Copy link
Member

Choose a reason for hiding this comment

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

Is this comment wrong or I misunderstand it? Looks like it returns batch as it asserts supportsBatch.

Copy link
Member Author

Choose a reason for hiding this comment

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

this is copied and pasted. will fix it.

return child.execute()
s"`${SQLConf.WHOLESTAGE_HUGE_METHOD_LIMIT.key}`:\n$treeString")
child match {
// For batch file source scan, we should continue executing it
Copy link
Member

Choose a reason for hiding this comment

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

It's better to explain why we should continue it. Otherwise later readers may not understand it immediately.

@viirya
Copy link
Member

viirya commented Oct 6, 2017

LGTM except two minor comments.

@SparkQA
Copy link

SparkQA commented Oct 6, 2017

Test build #82494 has finished for PR 19440 at commit b8eb6a0.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gatorsmile
Copy link
Member Author

Thanks! Merged to master.

@asfgit asfgit closed this in 83488cc Oct 6, 2017
rdblue pushed a commit to rdblue/spark that referenced this pull request Apr 3, 2019
…n spark.sql.codegen.hugeMethodLimit

When exceeding `spark.sql.codegen.hugeMethodLimit`, the runtime fallbacks to the Volcano iterator solution. This could cause an infinite loop when `FileSourceScanExec` can use the columnar batch to read the data. This PR is to fix the issue.

Added a test

Author: gatorsmile <[email protected]>

Closes apache#19440 from gatorsmile/testt.
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.

5 participants