Skip to content

Weird initialisation bug occurring only occasionally #10

Description

@polterguy

I've got the following sqlite-vector loader code.

using (var cmd = connection.CreateCommand())
{
    var cmdTxt = @"select load_extension(""./sqlite-plugins/vector"", ""sqlite3_vector_init"")";
    cmd.CommandText = cmdTxt;
    cmd.ExecuteNonQuery();
}

This code runs automatically every single time I create an SQLite connection, and it succeeds 99% of the time, but fails occasionally. The good news is that it fails consistently, as in only when using HttpClient with streaming (SSE, as in Server Side Events), and from the callback (implying a callback from server, hence also a new or previously suspended background thread since HttpClient is async).

I've tried creating all sorts of "reproducibles" with multiple threads creating database connections at the same time, but I can't reproduce it, and the only common denominator is that it's invoked from a callback supplied to HttpClient, which makes it ridiculously complex to create a reproducible.

The code is identical to the code I previously used for "sqlite-vec", so at least in theory there shouldn't be anything wrong with my code, but given my "funny thread configuration" it seems to fail consistently ...

Notice, the only SQL that it executes in the command can be seen above. The connection is 100% new, and I don't use connection pooling. See the attached screenshot for the exception that occurs ...

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions