Giorgi / DuckDB.NET

Bindings and ADO.NET Provider for DuckDB
https://duckdb.net
MIT License
338 stars 61 forks source link

Kills container with version 0.9.2 #161

Closed OneCyrus closed 7 months ago

OneCyrus commented 7 months ago

version 0.9.2 seems to have a bug which kills the full dotnet application when running in a container. not sure if it's an issue of the bindings or duckdb itself.

version 0.8.0 worked without an issue. basically just running code like kills the process without any error message:

 using var cmd = _connection.CreateCommand();
 cmd.CommandText =
     $"SET s3_access_key_id = '{s3config.GetAccessKey()}';"
     + $"SET s3_secret_access_key = '{s3config.GetSecretKey()}';"
     + $"SET s3_endpoint = '{s3config.GetEndpoint()}';"

 cmd.ExecuteNonQuery();
Giorgi commented 7 months ago

What happens if you run the same commands from DuckDB cli?

Also, can you put that code in try catch to see if you are able to catch the exception?

OneCyrus commented 7 months ago

i'm trying to do a repro. it seems to be related to manual installation of the httpfs extension.

OneCyrus commented 7 months ago

created a reproduction here: https://github.com/OneCyrus/duckdb-repro/

it's a simple webservice which should return a string on the root endpoint ("/"). when run as a linux container it never reaches the end of the method. also no exception is thrown. it basically just kills the whole process.

app.MapGet("/", (IWebHostEnvironment env) =>
{
    var _connection = new DuckDBConnection("DataSource=:memory:");
    _connection.Open();

    var extensionPath = Path.Combine(
         env.ContentRootPath,
         $"httpfs.duckdb_extension_92_linux"
     );

    using var cmd = _connection.CreateCommand();
    cmd.CommandText =
          $"INSTALL '{extensionPath}';"
        + $"LOAD '{extensionPath}';";

    cmd.ExecuteReader();

    return "Success!";
});
Giorgi commented 7 months ago

Does it work if you run those commands from cli?

OneCyrus commented 7 months ago

looks like it shows an error when using the cli in the container. but the process is still running. not sure what really happens there and what changed from 0.8.0.

D INSTALL 'httpfs.duckdb_extension_92_linux';
D LOAD 'httpfs.duckdb_extension_92_linux';
Error: IO Error: Extension "httpfs.duckdb_extension_92_linux" could not be loaded: httpfs.duckdb_extension_92_linux: cannot open shared object file: No such file or directory
D
Giorgi commented 7 months ago

Is the extension in the current folder for the cli?

If ExecuteReader throws an exception you should be able to catch it with try/catch.

OneCyrus commented 7 months ago

no exception is thrown. it just crashes the whole thing.

but I might have found the issue. it looks like the newer version needs a special version of the extension now. with the gcc4 version it seems to work. when loading then httpfs.duckdb_extension_92_linux_amd64_gcc4 file it doesn't crash anymore.

Giorgi commented 7 months ago

I suspect that loading an incompatible extension is causing access violation or some similar error that can't be caught by the .Net runtime. Glad that you got it working.

Giorgi commented 7 months ago

By the way, with version 0.9.3-alpha.11 of the package (only available on GitHub at the moment) you can specify S3 settings in the connection string.

See more details in the readme: Connection String Parameters