You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Spaarsh (via GitHub)" <gi...@apache.org> on 2025/01/14 18:33:51 UTC
[PR] Making the data_imdb and clickbench_1 functions atomic. [datafusion]
Spaarsh opened a new pull request, #14129:
URL: https://github.com/apache/datafusion/pull/14129
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #14128
## Rationale for this change
Due to non-atomic downloads, the user would need to manually remove files/folders created by the script in order to not encounter the "file already exists" error.
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
The changes primarily focus on adding traps for catching keyboard interrupts and failures in the process completion and reverting the changes if either of the two are encountered.
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## Are these changes tested?
Yes, these changes have been tested. The following are the results:
#### For the benchmarks/bench.sh data imdb command:

#### For the benchmarks/bench.sh data clickbench_1 command:

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Making the data_imdb and clickbench_1 functions atomic. [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #14129:
URL: https://github.com/apache/datafusion/pull/14129#discussion_r1920568890
##########
benchmarks/bench.sh:
##########
@@ -401,9 +405,14 @@ data_clickbench_1() {
else
URL="https://datasets.clickhouse.com/hits_compatible/hits.parquet"
echo -n "... downloading ${URL} (14GB) ... "
- wget --continue ${URL}
- fi
- echo " Done"
+ if ! wget --continue ${URL}; then
Review Comment:
I think the check above tests for the file size and already detects partial / failed previous downloads
```shell
if test "${OUTPUT_SIZE}" = "14779976446"; then
```
So I am not sure this is necessary
##########
benchmarks/bench.sh:
##########
@@ -455,13 +464,27 @@ run_clickbench_extended() {
$CARGO_COMMAND --bin dfbench -- clickbench --iterations 5 --path "${DATA_DIR}/hits.parquet" --queries-path "${SCRIPT_DIR}/queries/clickbench/extended.sql" -o "${RESULTS_FILE}"
}
+# Add cleanup function at the start of script
+cleanup_download() {
+ local file_to_clean="$1"
+ echo -e "\nCleaning up downloaded files..."
+ rm -f "${file_to_clean}"
+ exit 1
+}
+
+# Add trap before download starts
+trap cleanup_download INT TERM
+
# Downloads the csv.gz files IMDB datasets from Peter Boncz's homepage(one of the JOB paper authors)
# https://event.cwi.nl/da/job/imdb.tgz
data_imdb() {
local imdb_dir="${DATA_DIR}/imdb"
local imdb_temp_gz="${imdb_dir}/imdb.tgz"
local imdb_url="https://event.cwi.nl/da/job/imdb.tgz"
+ # Set trap with parameter
Review Comment:
Perhaps we can add a check for file size of the imdb.tgz file rather than just checking for its existence
```
if [ ! -f "${imdb_dir}/imdb.tgz" ]; then
```
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Making the data_imdb and clickbench_1 functions atomic. [datafusion]
Posted by "Spaarsh (via GitHub)" <gi...@apache.org>.
Spaarsh closed pull request #14129: Making the data_imdb and clickbench_1 functions atomic.
URL: https://github.com/apache/datafusion/pull/14129
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Making the data_imdb and clickbench_1 functions atomic. [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14129:
URL: https://github.com/apache/datafusion/pull/14129#issuecomment-2599712739
> But if we go for the static size, the solution is pretty straightforward. Should I go forward with it then?
That is my suggestion. I agree it won't cover all the cases but I think it will get the common problems and it is quite simple
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Making the data_imdb and clickbench_1 functions atomic. [datafusion]
Posted by "Spaarsh (via GitHub)" <gi...@apache.org>.
Spaarsh commented on PR #14129:
URL: https://github.com/apache/datafusion/pull/14129#issuecomment-2605437829
The suggested changes have been implemented and have been committed via another PR #14225. Hence I am closing this PR.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Making the data_imdb and clickbench_1 functions atomic. [datafusion]
Posted by "Spaarsh (via GitHub)" <gi...@apache.org>.
Spaarsh commented on PR #14129:
URL: https://github.com/apache/datafusion/pull/14129#issuecomment-2599702209
The special handling for 404 was for the case if we went for the dynamic size thing😅. My only concern is that we've already faced one issue due the website owners changing the url. If they so happen to change the dataset size as well, the static size shall lead to unexpected behavior again. Just trying to cover all the bases so that no issue along these lines occurs again. Or perhaps I'm focusing too much on a simple script😅.
But if we go for the static size, the solution is pretty straightforward. Should I go forward with it then?
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Making the data_imdb and clickbench_1 functions atomic. [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14129:
URL: https://github.com/apache/datafusion/pull/14129#issuecomment-2599712773
BTW thank you very much for working on this
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Making the data_imdb and clickbench_1 functions atomic. [datafusion]
Posted by "Spaarsh (via GitHub)" <gi...@apache.org>.
Spaarsh commented on PR #14129:
URL: https://github.com/apache/datafusion/pull/14129#issuecomment-2591568792
Even I was thinking the same! But I wanted to ensure first that the same directory isn't being used to store other files. Since I would be using the ```rm -rf``` command here, that data would've been removed too without any warning. There was also the concern of making it easier for subsequent developers to work on this. In case the ```imdb``` directory finds a new usecase, the function would have to be changed at that point.
I also planned to make the cleanup function as a util function. So that it can be used wherever atomicity was needed in the ```bench.sh``` , hence I wanted to make it as general as possible.
Would like your thoughts on this!
Thanks!
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Making the data_imdb and clickbench_1 functions atomic. [datafusion]
Posted by "Spaarsh (via GitHub)" <gi...@apache.org>.
Spaarsh commented on PR #14129:
URL: https://github.com/apache/datafusion/pull/14129#issuecomment-2599629191
@alamb your suggestions do make sense. Perhaps all that is needed is a size checking function. My addition would be to dynamically check for the expected size of the file to be transferred by running the following command first:
```
datafusion$ curl -sI https://event.cwi.nl/da/job/imdb.tgz | grep -i content-length
Content-Length: 1263193115
```
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Making the data_imdb and clickbench_1 functions atomic. [datafusion]
Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on PR #14129:
URL: https://github.com/apache/datafusion/pull/14129#issuecomment-2591584028
> Even I was thinking the same! But I wanted to ensure first that the same directory isn't being used to store other files.
I think the convention followed now is that the same subdirectory under `data/` can't hold different datasets.
However, I agree it’s safer to address this later, when we can ensure all datasets follow this rule.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Making the data_imdb and clickbench_1 functions atomic. [datafusion]
Posted by "Spaarsh (via GitHub)" <gi...@apache.org>.
Spaarsh commented on PR #14129:
URL: https://github.com/apache/datafusion/pull/14129#issuecomment-2599713336
> > But if we go for the static size, the solution is pretty straightforward. Should I go forward with it then?
>
> That is my suggestion. I agree it won't cover all the cases but I think it will get the common problems and it is quite simple
Agreed! I'll go forward with your suggested approach. Thanks!
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Making the data_imdb and clickbench_1 functions atomic. [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14129:
URL: https://github.com/apache/datafusion/pull/14129#issuecomment-2599696694
> @alamb your suggestions do make sense. Perhaps all that is needed is a size checking function. My addition would be to dynamically check for the expected size of the file to be transferred by running the following command first:
Since the file isn't expected to change, I would suggest simply hard coding the expected size in the bash script
As for 404 being returned, I don't understand why that would need special handling 🤔 If we had the hard coded expected size and a 404 was returned then the output file wouldn't be the right size so running the script again would ensure it was correct 🤔
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org