You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a DuckDB extension called shellfs, it derives from the FileSystem class and returns file handles that derive from FileHandle.
When there is a problem with a subprocess started by popen() the exit code or signal is only available once the pipe is closed with pclose(). I added the code that does the error checking and it throws an IOException when the subprocess exits with a non-zero exit code.
The problem is that the Close() method is only called as part of the destructor cleanup of the FileHandle. And in C++ throwing exceptions in destructors is a no no.
What is the recommended way to ensure that Close() is called on FileHandle implementations rather than just letting them be closed via destructors when the smart pointers are cleaned up?
I don't think there is any real way to do this at the moment, but for logging the error to some structure your extension owns, and then say rethrow at a later point that you control.
Thank you @carlopi, it feels really good that you liked the extension. I appreciate your compliment! DuckDB is awesome.
The problem is that the popen()'ed process's error should be associated with the executing query. So deferring notification to the user is kind of hard to do, but I'm going to think about your suggestion.
I don't see exactly either, it can be possibly hacked on, say by rewriting the query to be the regular query + a shellfs callback/cleanup, or something equivalent, but query execution is NOT my area, someone more at ease will pass with some feedback.
What happens?
I wrote a DuckDB extension called
shellfs
, it derives from the FileSystem class and returns file handles that derive from FileHandle.When there is a problem with a subprocess started by
popen()
the exit code or signal is only available once the pipe is closed withpclose()
. I added the code that does the error checking and it throws an IOException when the subprocess exits with a non-zero exit code.The problem is that the Close() method is only called as part of the destructor cleanup of the FileHandle. And in C++ throwing exceptions in destructors is a no no.
What is the recommended way to ensure that Close() is called on FileHandle implementations rather than just letting them be closed via destructors when the smart pointers are cleaned up?
Here is the code for the extension:
https://github.com/rustyconover/duckdb-shellfs-extension
Here is the backtrace for the error:
To Reproduce
With the
shellfs
extension installed just run:OS:
Mac OS X
DuckDB Version:
v0.10.2
DuckDB Client:
CLI
Full Name:
Rusty Conover
Affiliation:
n/a
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a stable release
Did you include all relevant data sets for reproducing the issue?
Yes
Did you include all code required to reproduce the issue?
Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
The text was updated successfully, but these errors were encountered: