Fix a couple of problems in handling OOM conditions within LSM.

FossilOrigin-Name: 989a5c1745a7145c14c6d9b713176ecba6b99296de8bdd09f666eeef10da9c2e
This commit is contained in:
dan 2017-07-04 17:25:45 +00:00
parent 92395c59ff
commit 038af0bdc6
4 changed files with 16 additions and 18 deletions

View File

@ -39,11 +39,9 @@ int lsmStringExtend(LsmString *pStr, int nNew){
lsmFree(pStr->pEnv, pStr->z);
nAlloc = 0;
pStr->n = -1;
pStr->z = 0;
}else{
pStr->nAlloc = nAlloc;
pStr->z = zNew;
}
pStr->nAlloc = nAlloc;
pStr->z = zNew;
}
return (pStr->z ? LSM_OK : LSM_NOMEM_BKPT);
}

View File

@ -1470,6 +1470,7 @@ static int treeInsertEntry(
rc = lsmTreeCursorSeek(&csr, pKey, nKey, &res);
pRes = csrGetKey(&csr, &csr.blob, &rc);
if( rc!=LSM_OK ) return rc;
assert( pRes );
if( flags==LSM_START_DELETE ){
/* When inserting a start-delete-range entry, if the key that
@ -1944,12 +1945,11 @@ void lsmTreeCursorReset(TreeCursor *pCsr){
}
#ifndef NDEBUG
static int treeCsrCompare(TreeCursor *pCsr, void *pKey, int nKey){
static int treeCsrCompare(TreeCursor *pCsr, void *pKey, int nKey, int *pRc){
TreeKey *p;
int cmp = 0;
int rc = LSM_OK;
assert( pCsr->iNode>=0 );
p = csrGetKey(pCsr, &pCsr->blob, &rc);
p = csrGetKey(pCsr, &pCsr->blob, pRc);
if( p ){
cmp = treeKeycmp(TKV_KEY(p), p->nKey, pKey, nKey);
}
@ -2051,8 +2051,8 @@ int lsmTreeCursorSeek(TreeCursor *pCsr, void *pKey, int nKey, int *pRes){
/* assert() that *pRes has been set properly */
#ifndef NDEBUG
if( rc==LSM_OK && lsmTreeCursorValid(pCsr) ){
int cmp = treeCsrCompare(pCsr, pKey, nKey);
assert( *pRes==cmp || (*pRes ^ cmp)>0 );
int cmp = treeCsrCompare(pCsr, pKey, nKey, &rc);
assert( rc!=LSM_OK || *pRes==cmp || (*pRes ^ cmp)>0 );
}
#endif

View File

@ -1,5 +1,5 @@
C Fix\sa\sproblem\sin\sthe\slempar.c\sLemon\stemplate\sfor\sYYSTACKDEPTH<=0\sintroduced\nby\scheck-in\s[36e54cd8b1fb37]
D 2017-07-04T12:50:00.595
C Fix\sa\scouple\sof\sproblems\sin\shandling\sOOM\sconditions\swithin\sLSM.
D 2017-07-04T17:25:45.084
F Makefile.in 081e48dfe7f995d57ce1a88ddf4d2917b4349158648a6cd45b42beae30de3a12
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 4ebb1d257cac7fb1bcb4ba59278416d410ff1c4bf59447a9c37a415f3516056a
@ -245,8 +245,8 @@ F ext/lsm1/lsm_mem.c 4c51ea9fa285ee6e35301b33491642d071740a0a
F ext/lsm1/lsm_mutex.c 378edf0a2b142b4f7640ee982df06d50b98788ea
F ext/lsm1/lsm_shared.c 54cc3a5157c6abd77f7d3ae60708b9f7bf022b3c
F ext/lsm1/lsm_sorted.c 105a4c0b95e6f8c1d03774f88afbf1397e7cacd52c1a4b24de1118d011d05fdd
F ext/lsm1/lsm_str.c 77ebdd5040ddf267a6f724d4c83132d2dce8a226
F ext/lsm1/lsm_tree.c 5d9fb2bc58a1a70c75126bd8d7198f7b627e165b
F ext/lsm1/lsm_str.c 65e361b488c87b10bf3e5c0070b14ffc602cf84f094880bece77bbf6678bca82
F ext/lsm1/lsm_tree.c 53b657439e0fcb1117b0559ad3567ac417f81f2ed0fff9bab79948a00ea3cacb
F ext/lsm1/lsm_unix.c 57361bcf5b1a1a028f5d66571ee490e9064d2cfb145a2cc9e5ddade467bb551b
F ext/lsm1/lsm_varint.c b19ae9bd26b5a1e8402fb8a564b25d9542338a41
F ext/lsm1/lsm_vtab.c 812b74a9a7539e8cab49761591ffddc1b3580735fac5d638826c8d2be95ff38b
@ -1628,7 +1628,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 9bd3be92b8add7bd0d7bc4b0742b2dd227ebb8d67a839b78f26f2b06b47490f2
R 6123d7ea6d11ea29ab25a0b4d8aef3db
U drh
Z c46d7ca565a10ec21d2e001f5aa7a07c
P 268a40f44cea6c3f561b7f54c90d631877be44292911424bac24f72c5ee87d60
R 29a4648a10525bedf183da8b85a862ca
U dan
Z dd241cb89313d1d4ce4db941dd142406

View File

@ -1 +1 @@
268a40f44cea6c3f561b7f54c90d631877be44292911424bac24f72c5ee87d60
989a5c1745a7145c14c6d9b713176ecba6b99296de8bdd09f666eeef10da9c2e