-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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-20848][SQL] Shutdown the pool after reading parquet files #18073
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,22 @@ import org.apache.spark.sql.test.SharedSQLContext | |
|
||
class ParquetFileFormatSuite extends QueryTest with ParquetTest with SharedSQLContext { | ||
|
||
test("Number of threads doesn't grow extremely after parquet file reading") { | ||
withTempDir { dir => | ||
val file = dir.toString + "/file" | ||
spark.range(1).toDF("a").coalesce(1).write.parquet(file) | ||
spark.read.parquet(file) | ||
val numThreadBefore = Thread.activeCount | ||
(1 to 100).map { _ => | ||
spark.read.parquet(file) | ||
} | ||
val numThreadAfter = Thread.activeCount | ||
// Hard to test a correct thread number, | ||
// but it shouldn't increase more than a reasonable number. | ||
assert(numThreadAfter - numThreadBefore < 20) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. after waiting for enough time, can we expect this to be 0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It reduces to a few (about 3) after waiting an enough time. The number returned by Thread.activeCount is only an estimate. So we may not expect this to be 0. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks hacky, can we think of a better way to test it? If not, I suggest to remove this test, as the fix is straightforward and we can verify it manually by some profile tools. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. Let's remove the test. |
||
} | ||
} | ||
|
||
test("read parquet footers in parallel") { | ||
def testReadFooters(ignoreCorruptFiles: Boolean): Unit = { | ||
withTempDir { dir => | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could probably put the shutdown in a finally block to avoid adding this new reference. I think you can rearrange to use the existing one below. It does help shut it down in case of an error too. Also I think you can hold a reference just to the ForkJoinPool in order to shut it down rather than a ref to ForkJoinTaskSupport. No big deal