-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
GH-37670: [C++] IO FileInterface extend from enable_shared_from_this #37713
GH-37670: [C++] IO FileInterface extend from enable_shared_from_this #37713
Conversation
|
ec41eee
to
624612b
Compare
Ooops.
If |
cpp/src/arrow/filesystem/s3fs.cc
Outdated
@@ -1472,36 +1515,9 @@ class ObjectOutputStream final : public io::OutputStream { | |||
RETURN_NOT_OK(UploadPart("", 0)); | |||
} | |||
|
|||
auto self = shared_from_this(); |
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.
Another problem is that we cannot call shared_from_this
in dtor ( https://stackoverflow.com/questions/28338978/stdenable-shared-from-this-is-it-allowed-to-call-shared-from-this-in-destru ), so I separate a FinishPartUploadAfterFlush
.
If that's the case, then we can move |
Sure, let me try it |
After some trying, we have However, because of the derive is virtual, we need to change // Default ReadMetadataAsync() implementation: simply issue the read on the context's
// executor
Future<std::shared_ptr<const KeyValueMetadata>> InputStream::ReadMetadataAsync(
const IOContext& ctx) {
std::shared_ptr<InputStream> self = std::dynamic_pointer_cast<InputStream>(shared_from_this());
return DeferNotOk(internal::SubmitIO(ctx, [self] { return self->ReadMetadata(); }));
} Do you think this is ok? @pitrou |
cc @bkietz for opinions on |
|
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.
This looks good, just a few nits
009d8cb
to
d87f09b
Compare
@bkietz I've resolve the comment, would you mind take a look again? |
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.
Sorry, I wasn't specific enough:
Co-authored-by: Benjamin Kietzman <[email protected]>
Hmm seems this is not caused by me...? |
Yes, that seems to be known flakiness #30568 I've restarted that CI job |
After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit 0e6a683. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about possible false positives for unstable benchmarks that are known to sometimes produce them. |
…_this (apache#37713) ### Rationale for this change S3 `FlushAsync` might has lifetime problem, this patch fixes that. ### What changes are included in this PR? 1. Move `enable_shared_from_this` to `FileInterface` 2. Update S3 `FlushAsync` 3. Implement sync Flush to avoid call `share_from_this` in dtor. ### Are these changes tested? no ### Are there any user-facing changes? no * Closes: apache#37670 Lead-authored-by: mwish <[email protected]> Co-authored-by: mwish <[email protected]> Co-authored-by: Benjamin Kietzman <[email protected]> Signed-off-by: Benjamin Kietzman <[email protected]>
…_this (apache#37713) ### Rationale for this change S3 `FlushAsync` might has lifetime problem, this patch fixes that. ### What changes are included in this PR? 1. Move `enable_shared_from_this` to `FileInterface` 2. Update S3 `FlushAsync` 3. Implement sync Flush to avoid call `share_from_this` in dtor. ### Are these changes tested? no ### Are there any user-facing changes? no * Closes: apache#37670 Lead-authored-by: mwish <[email protected]> Co-authored-by: mwish <[email protected]> Co-authored-by: Benjamin Kietzman <[email protected]> Signed-off-by: Benjamin Kietzman <[email protected]>
Rationale for this change
S3
FlushAsync
might has lifetime problem, this patch fixes that.What changes are included in this PR?
enable_shared_from_this
toFileInterface
FlushAsync
share_from_this
in dtor.Are these changes tested?
no
Are there any user-facing changes?
no