SQLite linked to plugin binary

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

SQLite linked to plugin binary

Carsten Müncheberg-2
I am running into a problem with the following use-case:
A host application (which is a black box for me I cannot change) is loading
my plugin binaries which each have SQLite linked statically. When two
plugins now access the same database file from the process of the host
application none of the serialization mechanisms (file lock, mutex) works,
and my database file will get corrupted eventually.

The technical reasons for this are understood by me, my question is whether
anyone of you can think of a solution for this unfortunate problem I am
stuck with.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: SQLite linked to plugin binary

Jens Alfke-2


> On Jan 23, 2019, at 8:27 AM, Carsten Müncheberg <[hidden email]> wrote:
>
> A host application (which is a black box for me I cannot change) is loading
> my plugin binaries which each have SQLite linked statically. When two
> plugins now access the same database file from the process of the host
> application none of the serialization mechanisms (file lock, mutex) works,
> and my database file will get corrupted eventually.

Build SQLite as a dynamic library, and link each of your plugins with it dynamically. (You may need an installation process that copies the SQLite library to a known location where each plugin can find it.)
Then there’s only one instance of SQLite, and locking should work properly.

(And if the platform is macOS or iOS, consider using the built-in system copy of SQLite instead of your own; that makes it even easier.)

—Jens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: SQLite linked to plugin binary

Clemens Ladisch
In reply to this post by Carsten Müncheberg-2
Carsten Müncheberg wrote:
> A host application (which is a black box for me I cannot change) is loading
> my plugin binaries which each have SQLite linked statically. When two
> plugins now access the same database file from the process of the host
> application none of the serialization mechanisms (file lock, mutex) works,

Not even unix-dotfile?

> my question is whether anyone of you can think of a solution for this
> unfortunate problem I am stuck with.

You could write your own VFS, with some other locking mechanism.


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: SQLite linked to plugin binary

Carsten Müncheberg-2
In reply to this post by Jens Alfke-2
Am Mi., 23. Jan. 2019 um 18:23 Uhr schrieb Jens Alfke <[hidden email]>:

>
>
> > On Jan 23, 2019, at 8:27 AM, Carsten Müncheberg <
> [hidden email]> wrote:
> >
> > A host application (which is a black box for me I cannot change) is
> loading
> > my plugin binaries which each have SQLite linked statically. When two
> > plugins now access the same database file from the process of the host
> > application none of the serialization mechanisms (file lock, mutex)
> works,
> > and my database file will get corrupted eventually.
>
> Build SQLite as a dynamic library, and link each of your plugins with it
> dynamically. (You may need an installation process that copies the SQLite
> library to a known location where each plugin can find it.)
> Then there’s only one instance of SQLite, and locking should work properly.
>
> (And if the platform is macOS or iOS, consider using the built-in system
> copy of SQLite instead of your own; that makes it even easier.)
>
> —Jens
>
> Yes, I was considering that, but wasn't sure if it would make a
difference, so I thought I'd better ask first.

Thanks.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users