> Le 9 juil. 2016 à 12:33, Simon Slavin <[email protected]> a écrit :
>
>> I'm really interested in knowing wether you use the engine in SERIALIZED or
>> MULTITHREADED mode during this event reproduction?
>
> In other words, please read the last part of
>
> <https://www.sqlite.org/threadsafe.html>
>
> and try to reproduce your problem in "Multi-thread" mode. If the problem
> still occurs, please try again in "Serialized" mode.
In between I had a quick look at sqlite3.c code. It looks like the source of
the issue is expected. The MULTITHREADED mode relaxes usage of mutexes, albeit
only on connections and statements structures. The remaining bits of the
engine still make uses of multiple mutexes to protect its integrity from
multiple threads using the engine.
See sqlite3BtreeOpen() and this section of code where the
SQLITE_MUTEX_STATIC_OPEN is acquired.
The SERIALIZED and MULTITHREADED modes both have SQLITE_THREADSAFE != 0 (which
is right).
#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
/*
** If this Btree is a candidate for shared cache, try to find an
** existing BtShared object that we can share with
*/
if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){
if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){
int nFilename = sqlite3Strlen30(zFilename)+1;
int nFullPathname = pVfs->mxPathname+1;
char *zFullPathname = sqlite3Malloc(MAX(nFullPathname,nFilename));
MUTEX_LOGIC( sqlite3_mutex *mutexShared; )
p->sharable = 1;
if( !zFullPathname ){
sqlite3_free(p);
return SQLITE_NOMEM_BKPT;
}
if( isMemdb ){
memcpy(zFullPathname, zFilename, nFilename);
}else{
rc = sqlite3OsFullPathname(pVfs, zFilename,
nFullPathname, zFullPathname);
if( rc ){
sqlite3_free(zFullPathname);
sqlite3_free(p);
return rc;
}
}
#if SQLITE_THREADSAFE
mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN);
sqlite3_mutex_enter(mutexOpen);
mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
sqlite3_mutex_enter(mutexShared);
#endif
The whole issue then revolves around the SHARED_CACHE/PRIVATE_CACHE and not the
SERIALIZED/MULTITHREADED mode. Chances are that if OP Brian tries the same
scenario with PRIVATE_CACHE connections, the issue will not occur.
I think this would probably qualify for an inherent limitation, which might be
documented, but not something necessarily undesirable.
--
Meilleures salutations, Met vriendelijke groeten, Best Regards,
Olivier Mascia, integral.be/om
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users