You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "joellubi (via GitHub)" <gi...@apache.org> on 2024/07/22 21:16:53 UTC

Re: [PR] GH-43359: [Go][Parquet] ReadRowGroups panics with canceled context [arrow]

joellubi commented on code in PR #43360:
URL: https://github.com/apache/arrow/pull/43360#discussion_r1687150550


##########
go/parquet/pqarrow/helpers.go:
##########
@@ -38,6 +38,8 @@ func releaseArrayData(data []arrow.ArrayData) {
 
 func releaseColumns(columns []arrow.Column) {
 	for _, col := range columns {
-		col.Release()
+		if col.Data() != nil { // data can be nil due to the way columns are constructed in ReadRowGroups

Review Comment:
   Can you please move this `nil` check to within the implementation of `Column.Release()` (and `Column.Retain()` as well) to help prevent this scenario from coming up elsewhere?



##########
go/parquet/pqarrow/file_reader.go:
##########
@@ -375,6 +375,12 @@ func (fr *FileReader) ReadRowGroups(ctx context.Context, indices, rowGroups []in
 		data.data.Release()
 	}
 
+	if ctxErr := ctx.Err(); err == nil && ctxErr != nil {
+		// if the context is in error, but we haven't set an error yet, then it means that the parent context
+		// was cancelled. In this case, we should exit early as some columns may not have been read yet.
+		err = ctxErr
+	}

Review Comment:
   This should be logically equivalent, just a little simpler:
   ```go
   if err == nil {
   	err = ctx.Err()
   }
   ```
   
   If you're up for testing it out, [errors.Join](https://pkg.go.dev/errors#Join) would be perfect for this but I'm not 100% sure it's supported on our current version of Go.



-- 
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