-
Notifications
You must be signed in to change notification settings - Fork 97
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
feat(go/adbc/driver/snowflake): support parameter binding #1808
Conversation
@zeroshade could you help figure out the ASAN error? Reducing SqlPrepareUpdateStream to this first part still seems to trigger it, so to me it seems like a GC issue again:
|
I tracked down the cause of the leak, it's not a GC issue. I filed an upstream PR to fix the leak in the cdata package of Go Arrow which is linked above |
### What changes are included in this PR? If the `imp.alloc.bufCount` is 0, indicating we did not import any buffers from the provided C ArrowArray object, then we are free to not only call the release callback (which we already do) but also we need to free the temp ArrowArray we allocated to move the source to. This was uncovered by apache/arrow-adbc#1808 * GitHub Issue: #41534 Authored-by: Matt Topol <zotthewizard@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
Hmm.
|
Still?? Wtf? |
I think I tracked it down to a missing release in one case, let's see :P |
@zeroshade can I just get a final look here once you're up? |
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.
LGTM just a couple nitpicks
case *array.Boolean: | ||
params[i].Value = sql.NullBool{ | ||
Bool: column.Value(index), | ||
Valid: column.IsValid(index), | ||
} |
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.
Something for us to think about is that go1.22 added sql.Null[T]
which might be useful to allow us to create a more generic implementation of this later on (since we officially still support go 1.21, we wouldn't be able to use it yet)
// technically, snowflake can bind an array of values at once, but | ||
// only for INSERT, so we can't take advantage of that without | ||
// analyzing the query ourselves |
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.
I hate this, but nothing we can do right now i guess
go/adbc/driver/snowflake/binding.go
Outdated
params, err := r.NextParams() | ||
if err != nil { | ||
return nil, err | ||
} else if params == nil { |
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.
no need for else
since we're returning in the previous condition
go/adbc/driver/snowflake/binding.go
Outdated
return nil, err | ||
} else if params == nil { | ||
// end-of-stream | ||
return nil, nil |
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.
nil
defines end-of-stream instead of using io.EOF
?
go/adbc/driver/snowflake/binding.go
Outdated
if r.currentBatch != nil { | ||
r.currentBatch.Release() | ||
} |
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.
we might still end up with a double release here because we don't set r.currentBatch
to nil
after calling stream.Next()
and getting the end of the stream. we should probably just always set r.currentBatch = nil
before we call stream.Next()
to ensure we don't double release. You can test for excess releases by running with -tags assert
which will turn on the debug asserts in Arrow
go/adbc/driver/snowflake/binding.go
Outdated
if r.stream != nil { | ||
r.stream.Release() | ||
} |
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.
we should probably also set both r.currentBatch
and r.stream
to nil
during release, just to prevent issues if release is called multiple times somehow
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.
LGTM
…41535) ### What changes are included in this PR? If the `imp.alloc.bufCount` is 0, indicating we did not import any buffers from the provided C ArrowArray object, then we are free to not only call the release callback (which we already do) but also we need to free the temp ArrowArray we allocated to move the source to. This was uncovered by apache/arrow-adbc#1808 * GitHub Issue: apache#41534 Authored-by: Matt Topol <zotthewizard@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
### What changes are included in this PR? If the `imp.alloc.bufCount` is 0, indicating we did not import any buffers from the provided C ArrowArray object, then we are free to not only call the release callback (which we already do) but also we need to free the temp ArrowArray we allocated to move the source to. This was uncovered by apache/arrow-adbc#1808 * GitHub Issue: #41534 Authored-by: Matt Topol <zotthewizard@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
Fixes #1144.