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-7862][SQL]Fix the deadlock in script transformation for stderr #6404

Closed
wants to merge 2 commits into from

Conversation

zhichao-li
Copy link
Contributor

val proc = builder.start()
val inputStream = proc.getInputStream
val outputStream = proc.getOutputStream
val reader = new BufferedReader(new InputStreamReader(inputStream))

Copy link
Member

Choose a reason for hiding this comment

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

PS your IDE settings are making spurious whitespace changes. It clutters the diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed config the "Strip trailing spaces on save" to be "ALL". Thanks for pointing this out.

@SparkQA
Copy link

SparkQA commented May 26, 2015

Test build #33507 has finished for PR 6404 at commit c419a64.

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

@SparkQA
Copy link

SparkQA commented May 27, 2015

Test build #33554 has finished for PR 6404 at commit d9677e1.

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

@zhichao-li
Copy link
Contributor Author

cc @rxin @liancheng @marmbrus

@marmbrus
Copy link
Contributor

/cc @chenghao-intel

@@ -58,6 +59,7 @@ case class ScriptTransformation(
child.execute().mapPartitions { iter =>
val cmd = List("/bin/bash", "-c", script)
val builder = new ProcessBuilder(cmd)
builder.redirectError(Redirect.INHERIT)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment explaining why this is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

builder.redirectError(Redirect.INHERIT) would consuming the error output from buffer and then print it to stderr (inherit the target from the current Scala process).
If without this there would be 2 issues:

  1. The error msg generated by the script process would be hidden.
  2. If the error msg is too big to chock up the buffer, the input logic would be hang (There's are simple steps on jira to reproduce this behavior).

Copy link
Contributor

Choose a reason for hiding this comment

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

Put the comment in the source code.

@chenghao-intel
Copy link
Contributor

LGTM

@SparkQA
Copy link

SparkQA commented Jun 12, 2015

Test build #34742 has finished for PR 6404 at commit 8418c97.

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

@marmbrus
Copy link
Contributor

Thanks, merging to master.

@asfgit asfgit closed this in 2dd7f93 Jun 12, 2015
@JoshRosen
Copy link
Contributor

After this patch, the pull request builder logs show 50000 lines of stdout output, which makes them hard to read:

[info] - test script transform for stdout (3 seconds, 806 milliseconds)
17:26:41.401 WARN org.apache.spark.scheduler.TaskSetManager: Stage 1316 contains a task of very large size (2246 KB). The maximum recommended task size is 100 KB.
1   1   1
2   2   2
3   3   3
4   4   4
5   5   5
6   6   6
7   7   7
8   8   8
9   9   9
10  10  10
11  11  11
12  12  12
13  13  13
14  14  14
15  15  15
16  16  16
17  17  17
18  18  18
19  19  19
20  20  20
21  21  21
22  22  22
23  23  23
24  24  24
25  25  25
[...]

At least I think that this is the patch that caused this issue. If that's the case, could someone open up a followup PR to fix this?

@chenghao-intel
Copy link
Contributor

Oh, sorry @JoshRosen the meaningless output is caused by #5671, I will fix it with a followup PR.

}

test("test script transform for stderr") {
val data = (1 to 100000).map { i => (i, i, i) }
Copy link
Contributor

Choose a reason for hiding this comment

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

This test will flush the stderr while testing, should we generate less data or hide it someway?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree. Filed SPARK-8508 and PR #6925 to shrink unnecessary output.

nemccarthy pushed a commit to nemccarthy/spark that referenced this pull request Jun 19, 2015
[Related PR SPARK-7044] (apache#5671)

Author: zhichao.li <zhichao.li@intel.com>

Closes apache#6404 from zhichao-li/transform and squashes the following commits:

8418c97 [zhichao.li] add comments and remove useless failAfter logic
d9677e1 [zhichao.li] redirect the error desitination to be the same as the current process
asfgit pushed a commit that referenced this pull request Jun 29, 2015
This is a follow up of #6404, the ScriptTransformation prints the error msg into stderr directly, probably be a disaster for application log.

Author: Cheng Hao <hao.cheng@intel.com>

Closes #6882 from chenghao-intel/verbose and squashes the following commits:

bfedd77 [Cheng Hao] revert the write
76ff46b [Cheng Hao] update the CircularBuffer
692b19e [Cheng Hao] check the process exitValue for ScriptTransform
47e0970 [Cheng Hao] Use the RedirectThread instead
1de771d [Cheng Hao] naming the threads in ScriptTransformation
8536e81 [Cheng Hao] disable the error message redirection for stderr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants