You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "DDtKey (via GitHub)" <gi...@apache.org> on 2023/02/06 11:06:10 UTC

[GitHub] [arrow-datafusion] DDtKey opened a new pull request, #5197: fix(MemTable): make it cancel-safe and fix parallelism

DDtKey opened a new pull request, #5197:
URL: https://github.com/apache/arrow-datafusion/pull/5197

   # Which issue does this PR close?
   
   The issue is close to #5178, but for `MemTable`.
   
   <!--
   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.
   -->
   
   # Rationale for this change
   
   1. It should be cancel-safe
   2. There was an issue with join - `await` was sequential
   3. There was possible to get a panic instead of 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?
   
   <!--
   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?
   
   Existed tests are passing
   
   <!--
   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@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] DDtKey commented on a diff in pull request #5197: fix(MemTable): make it cancel-safe and fix parallelism

Posted by "DDtKey (via GitHub)" <gi...@apache.org>.
DDtKey commented on code in PR #5197:
URL: https://github.com/apache/arrow-datafusion/pull/5197#discussion_r1097864800


##########
datafusion/core/src/datasource/memory.rs:
##########
@@ -76,20 +77,26 @@ impl MemTable {
             .map(|part_i| {
                 let task = state.task_ctx();
                 let exec = exec.clone();
-                tokio::spawn(async move {
+                let task = tokio::spawn(async move {
                     let stream = exec.execute(part_i, task)?;
                     common::collect(stream).await
-                })
+                });
+
+                AbortOnDropSingle::new(task)
             })
             // this collect *is needed* so that the join below can
             // switch between tasks
             .collect::<Vec<_>>();
 
         let mut data: Vec<Vec<RecordBatch>> =
             Vec::with_capacity(exec.output_partitioning().partition_count());
-        for task in tasks {
-            let result = task.await.expect("MemTable::load could not join task")?;
-            data.push(result);
+
+        for result in futures::future::join_all(tasks).await {
+            data.push(result.map_err(|_| {
+                DataFusionError::Internal(
+                    "MemTable::load could not join task".to_string(),
+                )

Review Comment:
   `Context` requires `DataFusionError`, so it's anyway should be wrapped to something 🤔 
   
   Could be `data.push(result.map_err(|e| DataFusionError::External(Box::new(e)))??)`, WDYT?



-- 
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@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5197: fix(MemTable): make it cancel-safe and fix parallelism

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5197:
URL: https://github.com/apache/arrow-datafusion/pull/5197#discussion_r1097757843


##########
datafusion/core/src/datasource/memory.rs:
##########
@@ -76,20 +77,26 @@ impl MemTable {
             .map(|part_i| {
                 let task = state.task_ctx();
                 let exec = exec.clone();
-                tokio::spawn(async move {
+                let task = tokio::spawn(async move {
                     let stream = exec.execute(part_i, task)?;
                     common::collect(stream).await
-                })
+                });
+
+                AbortOnDropSingle::new(task)
             })
             // this collect *is needed* so that the join below can
             // switch between tasks
             .collect::<Vec<_>>();
 
         let mut data: Vec<Vec<RecordBatch>> =
             Vec::with_capacity(exec.output_partitioning().partition_count());
-        for task in tasks {
-            let result = task.await.expect("MemTable::load could not join task")?;
-            data.push(result);
+
+        for result in futures::future::join_all(tasks).await {
+            data.push(result.map_err(|_| {
+                DataFusionError::Internal(
+                    "MemTable::load could not join task".to_string(),
+                )

Review Comment:
   I think it would help if we could preserve the original error here rather than turning it into an internal error
   
   Perhaps using `DataFusionError::Context`
   ```suggestion
               data.push(result.map_err(|e| {
                   DataFusionError::Context(
                       "MemTable::load could not join task".to_string(), Box::new(e)
                   )
   ```
   
   
   



-- 
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@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] DDtKey commented on a diff in pull request #5197: fix(MemTable): make it cancel-safe and fix parallelism

Posted by "DDtKey (via GitHub)" <gi...@apache.org>.
DDtKey commented on code in PR #5197:
URL: https://github.com/apache/arrow-datafusion/pull/5197#discussion_r1097971491


##########
datafusion/core/src/datasource/memory.rs:
##########
@@ -76,20 +77,26 @@ impl MemTable {
             .map(|part_i| {
                 let task = state.task_ctx();
                 let exec = exec.clone();
-                tokio::spawn(async move {
+                let task = tokio::spawn(async move {
                     let stream = exec.execute(part_i, task)?;
                     common::collect(stream).await
-                })
+                });
+
+                AbortOnDropSingle::new(task)
             })
             // this collect *is needed* so that the join below can
             // switch between tasks
             .collect::<Vec<_>>();
 
         let mut data: Vec<Vec<RecordBatch>> =
             Vec::with_capacity(exec.output_partitioning().partition_count());
-        for task in tasks {
-            let result = task.await.expect("MemTable::load could not join task")?;
-            data.push(result);
+
+        for result in futures::future::join_all(tasks).await {
+            data.push(result.map_err(|_| {
+                DataFusionError::Internal(
+                    "MemTable::load could not join task".to_string(),
+                )

Review Comment:
   Done 🙂 



-- 
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@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb merged pull request #5197: fix(MemTable): make it cancel-safe and fix parallelism

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #5197:
URL: https://github.com/apache/arrow-datafusion/pull/5197


-- 
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@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5197: fix(MemTable): make it cancel-safe and fix parallelism

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5197:
URL: https://github.com/apache/arrow-datafusion/pull/5197#discussion_r1097910053


##########
datafusion/core/src/datasource/memory.rs:
##########
@@ -76,20 +77,26 @@ impl MemTable {
             .map(|part_i| {
                 let task = state.task_ctx();
                 let exec = exec.clone();
-                tokio::spawn(async move {
+                let task = tokio::spawn(async move {
                     let stream = exec.execute(part_i, task)?;
                     common::collect(stream).await
-                })
+                });
+
+                AbortOnDropSingle::new(task)
             })
             // this collect *is needed* so that the join below can
             // switch between tasks
             .collect::<Vec<_>>();
 
         let mut data: Vec<Vec<RecordBatch>> =
             Vec::with_capacity(exec.output_partitioning().partition_count());
-        for task in tasks {
-            let result = task.await.expect("MemTable::load could not join task")?;
-            data.push(result);
+
+        for result in futures::future::join_all(tasks).await {
+            data.push(result.map_err(|_| {
+                DataFusionError::Internal(
+                    "MemTable::load could not join task".to_string(),
+                )

Review Comment:
   That would definitely be better than 👍 



-- 
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@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] ursabot commented on pull request #5197: fix(MemTable): make it cancel-safe and fix parallelism

Posted by "ursabot (via GitHub)" <gi...@apache.org>.
ursabot commented on PR #5197:
URL: https://github.com/apache/arrow-datafusion/pull/5197#issuecomment-1420587180

   Benchmark runs are scheduled for baseline = 816a0f8ff5768e5bc915bd6399de6512eb82e576 and contender = f63b97246ba9ee4a11baf15ff1001333f230b39b. f63b97246ba9ee4a11baf15ff1001333f230b39b is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/9cdc153daf914404911f82581a7b0225...1ceb717f20dd478ea0d6718ff1c2743f/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/857cd8e6750e4523b9fec6d0ff55977c...0b1644b30b0347688b46fb24ef00c199/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/37645f96fe894ba88296ab1be2f9a4d2...3ef13f2d3c5e47608ea2398067ed7037/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/5bd24f01d0774d3d855d52c62496458e...12d51477eca949659c66cb0a4b16726b/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org