Skip to content

Allow threadsafe insertion of blobs #255

@herzfeldd

Description

@herzfeldd

I recently ran into an issue where I happened to be sharing a DB connection across a Threads.@threads for loop. I am wondering if it would be useful to expose the sqlite3_config function (or a subset of the configuration) in api.jl to allow SQLite's threading mode to be selected. Something like:

function sqlite3_config_threads(thread_config::Int)
    return ccall( (:sqlite3_config, libsqlite),
        Cint, (Cint,),
        thread_config)
end

This way a user could specify sqlite3_config_threads(SQLite.SQLITE_CONFIG_SERIALIZED) before opening the first database, which should allow sharing the DB across Julia threads.

Or, even better yet (in my opinion) is SQLite.jl attempting to set SQLITE_CONFIG_SERIALIZED when the SQLite module is first loaded. I don't see a downside - assuming that the cost of the mutex inside the SQLite code base is pretty minimal for single threaded applications.

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