Streamline and improve testing of the locking in the memdb VFS.
Follow-on to [15f0be8a640e7bfa]. FossilOrigin-Name: d71a08375aeb525c10037c373b8eeb7e29f7dfaf7c4bfc02f4d99616c5940405
This commit is contained in:
parent
b54f71e205
commit
7c66faa634
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\s(harmless)\soff-by-one\serror\sin\scode\sgeneration\sthat\scomes\sup\swhen\ndoing\sa\sDISTINCT\squery\sagainst\sa\svirtual\stable\swith\san\sOR\sterm\sin\sthe\nWHERE\sclause\sand\swhere\sthe\sORDER\sBY\sclause\shas\s64\sor\smore\sreferences\sto\nthe\sresult\sset.\s\s[forum:/forumpost/dfe8084751|Forum\spost\sdfe8084751].
|
||||
D 2022-12-07T00:14:25.828
|
||||
C Streamline\sand\simprove\stesting\sof\sthe\slocking\sin\sthe\smemdb\sVFS.\nFollow-on\sto\s[15f0be8a640e7bfa].
|
||||
D 2022-12-07T16:58:04.002
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -615,7 +615,7 @@ F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
|
||||
F src/mem2.c c8bfc9446fd0798bddd495eb5d9dbafa7d4b7287d8c22d50a83ac9daa26d8a75
|
||||
F src/mem3.c 30301196cace2a085cbedee1326a49f4b26deff0af68774ca82c1f7c06fda4f6
|
||||
F src/mem5.c 5a3dbd8ac8a6501152a4fc1fcae9b0900c2d7eb0589c4ec7456fdde15725a26c
|
||||
F src/memdb.c fa280078fb48c4bb7ef47e361cd958938a1a3c46a9a45f6622da6efcb57cc055
|
||||
F src/memdb.c 3c1f3a3daa670294bad0056e66c17f5fe75cfa1da1850056a5a94347ec32e6bd
|
||||
F src/memjournal.c c283c6c95d940eb9dc70f1863eef3ee40382dbd35e5a1108026e7817c206e8a0
|
||||
F src/msvc.h 3a15918220367a8876be3fa4f2abe423a861491e84b864fb2b7426bf022a28f8
|
||||
F src/mutex.c 5e3409715552348732e97b9194abe92fdfcd934cfb681df4ba0ab87ac6c18d25
|
||||
@ -2067,8 +2067,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P bbde0f36d03cdbbc749427fe7d2dafd5c5031c9e655ebd772857b521f53eb18f
|
||||
R 250ed9b5c78a34895ae8f1ae12a9ecc7
|
||||
P 04af7ef77043702f93cbff23548610759786893bd3d4d6fc08181e1e249c6663
|
||||
R 12ec76fa12aeff3e27ce79fb7684d7d6
|
||||
U drh
|
||||
Z d0ffb89df284ba3dde1a0bb1536bd8ea
|
||||
Z af8ae60fb39ff0cbbaef800ceb1294d9
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
04af7ef77043702f93cbff23548610759786893bd3d4d6fc08181e1e249c6663
|
||||
d71a08375aeb525c10037c373b8eeb7e29f7dfaf7c4bfc02f4d99616c5940405
|
28
src/memdb.c
28
src/memdb.c
@ -370,21 +370,33 @@ static int memdbLock(sqlite3_file *pFile, int eLock){
|
||||
int rc = SQLITE_OK;
|
||||
if( eLock==pThis->eLock ) return SQLITE_OK;
|
||||
memdbEnter(p);
|
||||
assert( p->nWrLock==0 || p->nWrLock==1 ); /* No more than 1 write lock */
|
||||
if( eLock>SQLITE_LOCK_SHARED ){
|
||||
assert( pThis->eLock>=SQLITE_LOCK_SHARED );
|
||||
if( p->mFlags & SQLITE_DESERIALIZE_READONLY ){
|
||||
rc = SQLITE_READONLY;
|
||||
}else if( eLock==SQLITE_LOCK_EXCLUSIVE ){
|
||||
/* Taking an EXCLUSIVE lock. Fail if we only have SHARED and any
|
||||
** other client has any kind of write-lock. Also fail if any other
|
||||
** client is holding read-lock. */
|
||||
if( pThis->eLock<=SQLITE_LOCK_SHARED && p->nWrLock ){
|
||||
rc = SQLITE_BUSY;
|
||||
}else if( p->nRdLock>1 ){
|
||||
/* We never go for an EXCLUSIVE lock unless we already hold SHARED or
|
||||
** higher */
|
||||
assert( pThis->eLock>=SQLITE_LOCK_SHARED );
|
||||
testcase( pThis->eLock==SQLITE_LOCK_SHARED );
|
||||
|
||||
/* Because we are holding SHARED or more, there must be at least
|
||||
** one read lock */
|
||||
assert( p->nRdLock>0 );
|
||||
|
||||
/* The only way that there can be an existing write lock is if we
|
||||
** currently hold it. Otherwise, we would have never been able to
|
||||
** promote from NONE to SHARED. */
|
||||
assert( p->nWrLock==0 || pThis->eLock>SQLITE_LOCK_SHARED );
|
||||
|
||||
if( p->nRdLock>1 ){
|
||||
/* Cannot take EXCLUSIVE if somebody else is holding SHARED */
|
||||
rc = SQLITE_BUSY;
|
||||
}else{
|
||||
p->nWrLock = 1;
|
||||
}
|
||||
p->nWrLock = 1;
|
||||
}else if( pThis->eLock<=SQLITE_LOCK_SHARED ){
|
||||
}else if( ALWAYS(pThis->eLock<=SQLITE_LOCK_SHARED) ){
|
||||
/* Upgrading to RESERVED or PENDING from SHARED. Fail if any other
|
||||
** client has a write-lock of any kind. */
|
||||
if( p->nWrLock ){
|
||||
|
Loading…
x
Reference in New Issue
Block a user