You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/07/30 06:27:58 UTC
[GitHub] [spark] wForget opened a new pull request, #37346: [SPARK-37210] Allow forced use of staging directory
wForget opened a new pull request, #37346:
URL: https://github.com/apache/spark/pull/37346
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'core/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
Add `forceUseStagingDir` config to force use of staging dir when writing.
When setting `forceUseStagingDir` to true, I set `committerOutputPath` to staging dir in `InsertIntoHadoopFsRelationCommand` and for `HadoopMapReduceCommitProtocol.newTaskTempFile` method I calculate absolute dir and call `newTaskTempFileAbsPath`.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
As discussed in [SPARK-37210](https://issues.apache.org/jira/browse/SPARK-37210), errors or data loss may occur under some concurrent write scenarios.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
Added test case in `InsertSuite`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] wForget commented on pull request #37346: [SPARK-37210][CORE][SQL] Allow forced use of staging directory
Posted by GitBox <gi...@apache.org>.
wForget commented on PR #37346:
URL: https://github.com/apache/spark/pull/37346#issuecomment-1203698792
> The usecase looks suspicious to me. Is it a valid one? I'm not sure that `InsertIntoHadoopFsRelationCommand` guarantees concurrent writing to same table.
It seems a reasonable requirement to concurrently write to different partitions of the same table. Is there some blocking issues?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] wForget commented on pull request #37346: [SPARK-37210][CORE][SQL] Allow forced use of staging directory
Posted by GitBox <gi...@apache.org>.
wForget commented on PR #37346:
URL: https://github.com/apache/spark/pull/37346#issuecomment-1201989180
> Why it is an issue particular for `InsertIntoHadoopFsRelationCommand`?
`InsertIntoHiveTable` always uses hive staging dir https://github.com/apache/spark/blob/b0c831d3408dddfbbf3acacbe8100a9e08b400de/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala#L107
`InsertIntoHadoopFsRelationCommand` only uses spark staging dir in dynamic overwrite mode, otherwise it uses `table_location/_temporary` which leads to concurrency conflicts.
https://github.com/apache/spark/blob/b0c831d3408dddfbbf3acacbe8100a9e08b400de/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InsertIntoHadoopFsRelationCommand.scala#L171
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] github-actions[bot] commented on pull request #37346: [SPARK-37210][CORE][SQL] Allow forced use of staging directory
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #37346:
URL: https://github.com/apache/spark/pull/37346#issuecomment-1312282414
We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-37210][CORE][SQL] Allow forced use of staging directory [spark]
Posted by "zhengchenyu (via GitHub)" <gi...@apache.org>.
zhengchenyu commented on PR #37346:
URL: https://github.com/apache/spark/pull/37346#issuecomment-3397018906
@viirya @wForget @dongjoon-hyun
I found the same phenomenon. I have this audit log.
```
# first rename op
cmd=rename src=/user/testuser/testdb.db/test_table/_temporary/0/task_xxx/pt=20250908000000
dst=/user/testuser/testdb.db/test_table/pt=20250908000000
# second delete op
cmd=delete src=/user/testuser/testdb.db/test_table/_temporary
```
For any partition application, will delete `/user/testuser/testdb.db/test_table/_temporary`. When multiple application for different partitions are running at the same time, data loss may occur. we can just solve this problem to replace `/user/testuser/testdb.db/test_table/_temporary` with a unique directory.
How about reopen this PR? And I think the use case is not suspicious. For example, if I want to recalculate the partition data for the last month, I will run multiple application in parallel.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] github-actions[bot] closed pull request #37346: [SPARK-37210][CORE][SQL] Allow forced use of staging directory
Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #37346: [SPARK-37210][CORE][SQL] Allow forced use of staging directory
URL: https://github.com/apache/spark/pull/37346
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] wForget commented on pull request #37346: [SPARK-37210] Allow forced use of staging directory
Posted by GitBox <gi...@apache.org>.
wForget commented on PR #37346:
URL: https://github.com/apache/spark/pull/37346#issuecomment-1200101803
Hi @dongjoon-hyun , could you please help me review it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #37346: [SPARK-37210][CORE][SQL] Allow forced use of staging directory
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on PR #37346:
URL: https://github.com/apache/spark/pull/37346#issuecomment-1201742819
Thank you for making a PR, @wForget .
To @viirya and @sunchao . This issue has a reproducible example in the JIRA.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #37346: [SPARK-37210] Allow forced use of staging directory
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on PR #37346:
URL: https://github.com/apache/spark/pull/37346#issuecomment-1200388856
Can one of the admins verify this patch?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-37210][CORE][SQL] Allow forced use of staging directory [spark]
Posted by "zhengchenyu (via GitHub)" <gi...@apache.org>.
zhengchenyu commented on PR #37346:
URL: https://github.com/apache/spark/pull/37346#issuecomment-3401003005
@viirya @dongjoon-hyun @wForget
After some research, I discovered that the `.spark_staging_xxx` directory is only used for custom partition paths (introduced in https://github.com/apache/spark/pull/15814) and dynamic partitions overwrite (introduced in https://github.com/apache/spark/pull/18714, with appropriate modifications in https://github.com/apache/spark/pull/29000). I suspect the purpose of introducing `.spark_staging_xxx` is to avoid conflicts, for example, in scenarios where dynamic partitions overwrite to prevent data contamination.
I believe the issue of running multiple partitions application in parallel is similar to the two above. Could we make writing to `.spark_staging_xxx` as the default behavior? This would not only solve this problem but also make the code structure more clean?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-37210][CORE][SQL] Allow forced use of staging directory [spark]
Posted by "zhengchenyu (via GitHub)" <gi...@apache.org>.
zhengchenyu commented on code in PR #37346:
URL: https://github.com/apache/spark/pull/37346#discussion_r2435447191
##########
core/src/main/scala/org/apache/spark/internal/io/HadoopMapReduceCommitProtocol.scala:
##########
@@ -125,22 +126,27 @@ class HadoopMapReduceCommitProtocol(
taskContext: TaskAttemptContext, dir: Option[String], spec: FileNameSpec): String = {
val filename = getFilename(taskContext, spec)
- val stagingDir: Path = committer match {
- // For FileOutputCommitter it has its own staging path called "work path".
- case f: FileOutputCommitter =>
- if (dynamicPartitionOverwrite) {
- assert(dir.isDefined,
- "The dataset to be written must be partitioned when dynamicPartitionOverwrite is true.")
- partitionPaths += dir.get
- }
- new Path(Option(f.getWorkPath).map(_.toString).getOrElse(path))
- case _ => new Path(path)
- }
+ if (forceUseStagingDir && !dynamicPartitionOverwrite) {
Review Comment:
when `spark.sql.hive.convertMetastoreParquet` or `spark.sql.hive.convertMetastoreOrc` is `false`, mean use hive serde. We also call `newTaskTempFileAbsPath`. Here will trigger rename. I suspect this is a conflict with hive serde logic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org