Make the benign-fault setting recursive. Make all malloc failures

during a rollback benign since there is nothing we can do about them. (CVS 5128)

FossilOrigin-Name: a9d1d931358637a6f039723a053098f65530de4b
This commit is contained in:
drh 2008-05-13 13:27:33 +00:00
parent d138c0168f
commit 4873d5f614
12 changed files with 67 additions and 51 deletions

View File

@ -1,5 +1,5 @@
C Update\sthe\spager\sso\sthat\sit\sdoes\snot\stry\sto\scommit\sa\stransaction\sif\sthere\nhave\sbeen\sno\schanges\sto\sthe\sdatabase.\s(CVS\s5127)
D 2008-05-13T00:58:18
C Make\sthe\sbenign-fault\ssetting\srecursive.\s\sMake\sall\smalloc\sfailures\nduring\sa\srollback\sbenign\ssince\sthere\sis\snothing\swe\scan\sdo\sabout\sthem.\s(CVS\s5128)
D 2008-05-13T13:27:34
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 79aeba12300a54903f1b1257c1e7c190234045dd
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -83,7 +83,7 @@ F src/alter.c cc38b9e2a8cf19428f64e5da7ec4da35b7c02779
F src/analyze.c 9ee63497ee720728abe630d169ab91323ac7519c
F src/attach.c 496cc628b2e8c4d8db99d7c136761fcbebd8420b
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
F src/bitvec.c 8ec2212cfb702bc4f402c0b7ae7623d85320c714
F src/bitvec.c ab50c4b8c6a899dae499f5a805eebe4223c78269
F src/btmutex.c 483ced3c52205b04b97df69161fadbf87f4f1ea2
F src/btree.c 7bee6ba457f3e241911fab69b1602eb43c65b438
F src/btree.h 8826591bf54dd35fcf2e67473d5f1bae253861c7
@ -94,15 +94,15 @@ F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
F src/date.c e41ce4513fb0e359dc678d6bddb4ace135fe365d
F src/delete.c d3fc5987f2eb88f7b9549d58a5dfea079a83fe8b
F src/expr.c 89f192b22b8c06b61d9b944cb59f42370d80e362
F src/fault.c 83057e86815d473e526f7df0b0108dfdd022ff23
F src/fault.c f8728f9020a5da56cef8e4c69ca46790da193bbb
F src/func.c 77a910a1ca7613d291fd0b5cba3be14c02f0dce0
F src/hash.c 522a8f5a23cf18fe5845afee7263c5be76c25ca2
F src/hash.c fd8cb06fb54c2fe7d48c9195792059a2e5be8b70
F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53
F src/insert.c 77f0829b3e2edd19e9238195c56b0d56ab000f17
F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
F src/legacy.c 8267890e6a0a71f13b680794520999c642299081
F src/loadext.c 48455156d6044141d7e332c1b0b4647b3b8b8e66
F src/main.c 4c9ac364c1022b31ce3310ee5899e73e4b53db38
F src/main.c 2d1cf908a2e874f9bad7e8bff6b93c057dff6ba7
F src/malloc.c 12c1ae98ef1eff34b13c9eb526e0b7b479e1e820
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/mem1.c fc716ff521b6dd3e43eaa211967383308800e70a
@ -121,7 +121,7 @@ F src/os_common.h e8b748b2f2ecc8a498e50bfe5d8721f189c19d2a
F src/os_os2.c 0c3a5802bc4fdb7cb5f66771552b081c4e48a216
F src/os_unix.c a810e2aefdaddacf479407f76f8f4ca381d231b2
F src/os_win.c 3a60bddd07ea6f8adb2314dd5996ac97b988f403
F src/pager.c 8c222e8a89390005bdf2f5800d118c0d48a47522
F src/pager.c 2607309c4848bfb8a5766d94d74157b54a44c6c0
F src/pager.h 4f051fd856de6fd3c19aef5f82eace54122b9173
F src/parse.y fc4bd35c6088901f7c8daead26c6fb11c87d22e7
F src/pragma.c 2e4bb2e76e48a32750529fdc4bfe86ac5f54e01b
@ -132,7 +132,7 @@ F src/select.c da43ce3080112aa77863e9c570c1df19a892acb8
F src/shell.c 668ad976716982eb658019eda489b6f55131dbe7
F src/sqlite.h.in 5fafd7849e3e74625533144ce0ab9d495c0320da
F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3
F src/sqliteInt.h c38fad42820bd3a68cdb185edbea9aff8bf5c18b
F src/sqliteInt.h 70a2b0bf856bbdb86b10d994ea863f6591ab7144
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
F src/table.c 46ccf9b7892a86f57420ae7bac69ecd5e72d26b5
F src/tclsqlite.c c57e740e30bd6dda678796eed62c7f0e64689834
@ -143,7 +143,7 @@ F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071
F src/test5.c 3a6a5717a149d7ca2e6d14f5be72cf7555d54dc4
F src/test6.c 62281c0a9ac0265e579065942f7de4e080f8eb05
F src/test7.c acec2256c7c2d279db5a8b5fa1a2a68fcc942c67
F src/test8.c beca53180c42ee388c0c882a529739d3d1001f99
F src/test8.c bfebbeed68c86bab495256390636d39d195d3f1a
F src/test9.c 4615ef08750245a2d96aaa7cbe2fb4aff2b57acc
F src/test_async.c 3147c64c34721f088d5ab20f85dabd5d7732c007
F src/test_autoext.c 5e892ab84aece3f0428920bf46923f16ac83962a
@ -167,11 +167,11 @@ F src/update.c 2d7143b9014e955509cc4f323f9a9584fb898f34
F src/utf.c 8c94fa10efc78c2568d08d436acc59df4df7191b
F src/util.c 4f0125fa1ba77be12e30e1b234352fc1b5abfe00
F src/vacuum.c c3b2b70677f874102b8753bf494c232e777f3998
F src/vdbe.c 56c11eb1493296ef6da5bbc049e77b795824bdc7
F src/vdbe.c 81035a619a605412a782c1f01ffeb924e08759da
F src/vdbe.h f4bb70962d9c13e0f65b215c90e8acea1ae6e8ee
F src/vdbeInt.h 18aebaa7857de4507d92ced62d8fe0844671a681
F src/vdbeapi.c 95ed14a59c509f98c64afba30cd18c3c8cf649cd
F src/vdbeaux.c b98643abd85ae19318ee823f79168ae99b3a512e
F src/vdbeaux.c 7823f1db7f47cf70d86d1901e2030309e1cbfd02
F src/vdbeblob.c 554736781ee273a8089c776e96bdb53e66f57ce6
F src/vdbefifo.c a30c237b2a3577e1415fb6e288cbb6b8ed1e5736
F src/vdbemem.c 8397a763e8cc5932b16b19daee1f8094f15f9a7d
@ -368,7 +368,7 @@ F test/lock4.test 09d97d52cae18fadfe631552af9880dac6b3ae90
F test/main.test 82c222989e02ea09abd58d453828ffd71806b6bf
F test/malloc.test fa208f99ed283b131ace2903f052375ab480de1a
F test/malloc2.test 6f2abc0617a7df210381272681d598488a3bf943
F test/malloc3.test 9943abf6348413d37a24aaf9cea3b3b17d638892
F test/malloc3.test b0bc1427574358f715e8d4379e16642089996703
F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
F test/malloc5.test 1a68e56e513eab54d8c4cd1b769ff1d14e3f99f4
F test/malloc6.test 2f039d9821927eacae43e1831f815e157659a151
@ -634,7 +634,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P bd654ebdbe752b44f801726eea16f40aa27df920
R 939b509f9ae1dcc4659bd81429c6ffa4
P f1ed3689239098e0630e8d61f52971bcdf2801b6
R d7bb146d74af3e1e4d1db38ff35aa3b2
U drh
Z 4c32af911b8a7565a24f7a57dac06542
Z 71aaa427251ef7c78206e20cadcf791d

View File

@ -1 +1 @@
f1ed3689239098e0630e8d61f52971bcdf2801b6
a9d1d931358637a6f039723a053098f65530de4b

View File

@ -32,7 +32,7 @@
** start of a transaction, and is thus usually less than a few thousand,
** but can be as large as 2 billion for a really big database.
**
** @(#) $Id: bitvec.c,v 1.4 2008/04/14 01:00:58 drh Exp $
** @(#) $Id: bitvec.c,v 1.5 2008/05/13 13:27:34 drh Exp $
*/
#include "sqliteInt.h"
@ -140,9 +140,9 @@ int sqlite3BitvecSet(Bitvec *p, u32 i){
u32 bin = (i-1)/p->iDivisor;
i = (i-1)%p->iDivisor + 1;
if( p->u.apSub[bin]==0 ){
sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 1);
sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC);
p->u.apSub[bin] = sqlite3BitvecCreate( p->iDivisor );
sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0);
sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC);
if( p->u.apSub[bin]==0 ) return SQLITE_NOMEM;
}
return sqlite3BitvecSet(p->u.apSub[bin], i);

View File

@ -42,7 +42,7 @@ static struct FaultInjector {
int nBenign; /* Number of benign failures seen since last config */
int nFail; /* Number of failures seen since last config */
u8 enable; /* True if enabled */
u8 benign; /* True if next failure will be benign */
i16 benign; /* Positive if next failure will be benign */
} aFault[SQLITE_FAULTINJECTOR_COUNT];
/*
@ -104,14 +104,26 @@ int sqlite3FaultPending(int id){
** will continue to function normally. So a malloc failure during
** a hash table resize is a benign fault.
*/
void sqlite3FaultBenign(int id, int enable){
void sqlite3FaultBeginBenign(int id){
if( id<0 ){
for(id=0; id<SQLITE_FAULTINJECTOR_COUNT; id++){
aFault[id].benign = enable;
aFault[id].benign++;
}
}else{
assert( id>=0 && id<SQLITE_FAULTINJECTOR_COUNT );
aFault[id].benign = enable;
aFault[id].benign++;
}
}
void sqlite3FaultEndBenign(int id){
if( id<0 ){
for(id=0; id<SQLITE_FAULTINJECTOR_COUNT; id++){
assert( aFault[id].benign>0 );
aFault[id].benign--;
}
}else{
assert( id>=0 && id<SQLITE_FAULTINJECTOR_COUNT );
assert( aFault[id].benign>0 );
aFault[id].benign--;
}
}
@ -140,7 +152,7 @@ int sqlite3FaultStep(int id){
}
sqlite3Fault();
aFault[id].nFail++;
if( aFault[id].benign ){
if( aFault[id].benign>0 ){
aFault[id].nBenign++;
}
aFault[id].nRepeat--;

View File

@ -12,7 +12,7 @@
** This is the implementation of generic hash-tables
** used in SQLite.
**
** $Id: hash.c,v 1.27 2008/04/02 18:33:08 drh Exp $
** $Id: hash.c,v 1.28 2008/05/13 13:27:34 drh Exp $
*/
#include "sqliteInt.h"
#include <assert.h>
@ -233,9 +233,9 @@ static void rehash(Hash *pH, int new_size){
** is benign (since failing to resize a hash table is a performance
** hit only, not a fatal error).
*/
sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, pH->htsize>0);
if( pH->htsize>0 ) sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC);
new_ht = (struct _ht *)sqlite3MallocZero( new_size*sizeof(struct _ht) );
sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0);
if( pH->htsize>0 ) sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC);
if( new_ht==0 ) return;
sqlite3_free(pH->ht);

View File

@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.438 2008/05/05 16:56:35 drh Exp $
** $Id: main.c,v 1.439 2008/05/13 13:27:34 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -254,7 +254,7 @@ void sqlite3RollbackAll(sqlite3 *db){
int i;
int inTrans = 0;
assert( sqlite3_mutex_held(db->mutex) );
sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 1);
sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC);
for(i=0; i<db->nDb; i++){
if( db->aDb[i].pBt ){
if( sqlite3BtreeIsInTrans(db->aDb[i].pBt) ){
@ -265,7 +265,7 @@ void sqlite3RollbackAll(sqlite3 *db){
}
}
sqlite3VtabRollback(db);
sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0);
sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC);
if( db->flags&SQLITE_InternChanges ){
sqlite3ExpirePreparedStatements(db);

View File

@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.445 2008/05/13 00:58:18 drh Exp $
** @(#) $Id: pager.c,v 1.446 2008/05/13 13:27:34 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@ -688,9 +688,9 @@ static void pager_resize_hash_table(Pager *pPager, int N){
if( N==pPager->nHash ) return;
#endif
pagerLeave(pPager);
sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, pPager->aHash!=0);
if( pPager->aHash!=0 ) sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC);
aHash = sqlite3MallocZero( sizeof(aHash[0])*N );
sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0);
if( pPager->aHash!=0 ) sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC);
pagerEnter(pPager);
if( aHash==0 ){
/* Failure to rehash is not an error. It is only a performance hit. */
@ -1358,7 +1358,9 @@ static void pager_unlock(Pager *pPager){
static void pagerUnlockAndRollback(Pager *p){
/* assert( p->state>=PAGER_RESERVED || p->journalOpen==0 ); */
if( p->errCode==SQLITE_OK && p->state>=PAGER_RESERVED ){
sqlite3FaultBeginBenign(-1);
sqlite3PagerRollback(p);
sqlite3FaultEndBenign(-1);
}
pager_unlock(p);
#if 0
@ -2761,13 +2763,13 @@ int sqlite3PagerClose(Pager *pPager){
#endif
disable_simulated_io_errors();
sqlite3FaultBenign(-1, 1);
sqlite3FaultBeginBenign(-1);
pPager->errCode = 0;
pPager->exclusiveMode = 0;
pager_reset(pPager);
pagerUnlockAndRollback(pPager);
enable_simulated_io_errors();
sqlite3FaultBenign(-1, 0);
sqlite3FaultEndBenign(-1);
PAGERTRACE2("CLOSE %d\n", PAGERID(pPager));
IOTRACE(("CLOSE %p\n", pPager))
if( pPager->journalOpen ){

View File

@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.703 2008/05/09 18:03:14 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.704 2008/05/13 13:27:34 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@ -2170,14 +2170,16 @@ CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
int sqlite3FaultFailures(int);
int sqlite3FaultBenignFailures(int);
int sqlite3FaultPending(int);
void sqlite3FaultBenign(int,int);
void sqlite3FaultBeginBenign(int);
void sqlite3FaultEndBenign(int);
int sqlite3FaultStep(int);
#else
# define sqlite3FaultConfig(A,B,C)
# define sqlite3FaultFailures(A) 0
# define sqlite3FaultBenignFailures(A) 0
# define sqlite3FaultPending(A) (-1)
# define sqlite3FaultBenign(A,B)
# define sqlite3FaultBeginBenign(A)
# define sqlite3FaultEndBenign(A)
# define sqlite3FaultStep(A) 0
#endif

View File

@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test8.c,v 1.63 2008/05/05 13:23:04 drh Exp $
** $Id: test8.c,v 1.64 2008/05/13 13:27:34 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@ -1065,9 +1065,9 @@ static int echoCommit(sqlite3_vtab *tab){
** a transaction */
assert( pVtab->inTransaction );
sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 1);
sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC);
rc = echoTransactionCall(tab, "xCommit");
sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0);
sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC);
pVtab->inTransaction = 0;
return rc;
}

View File

@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.739 2008/05/09 18:03:14 drh Exp $
** $Id: vdbe.c,v 1.740 2008/05/13 13:27:34 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -559,7 +559,7 @@ int sqlite3VdbeExec(
CHECK_FOR_INTERRUPT;
sqlite3VdbeIOTraceSql(p);
#ifdef SQLITE_DEBUG
sqlite3FaultBenign(-1, 1);
sqlite3FaultBeginBenign(-1);
if( p->pc==0 && ((p->db->flags & SQLITE_VdbeListing)!=0
|| sqlite3OsAccess(db->pVfs, "vdbe_explain", SQLITE_ACCESS_EXISTS)==1 )
){
@ -573,7 +573,7 @@ int sqlite3VdbeExec(
if( sqlite3OsAccess(db->pVfs, "vdbe_trace", SQLITE_ACCESS_EXISTS)==1 ){
p->trace = stdout;
}
sqlite3FaultBenign(-1, 0);
sqlite3FaultEndBenign(-1);
#endif
for(pc=p->pc; rc==SQLITE_OK; pc++){
assert( pc>=0 && pc<p->nOp );
@ -595,11 +595,11 @@ int sqlite3VdbeExec(
sqlite3VdbePrintOp(p->trace, pc, pOp);
}
if( p->trace==0 && pc==0 ){
sqlite3FaultBenign(-1, 1);
sqlite3FaultBeginBenign(-1);
if( sqlite3OsAccess(db->pVfs, "vdbe_sqltrace", SQLITE_ACCESS_EXISTS)==1 ){
sqlite3VdbePrintSql(p);
}
sqlite3FaultBenign(-1, 0);
sqlite3FaultEndBenign(-1);
}
#endif

View File

@ -14,7 +14,7 @@
** to version 2.8.7, all this code was combined into the vdbe.c source file.
** But that file was getting too big so this subroutines were split out.
**
** $Id: vdbeaux.c,v 1.382 2008/05/08 15:18:10 drh Exp $
** $Id: vdbeaux.c,v 1.383 2008/05/13 13:27:34 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -1392,14 +1392,14 @@ static int vdbeCommit(sqlite3 *db){
** may be lying around. Returning an error code won't help matters.
*/
disable_simulated_io_errors();
sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 1);
sqlite3FaultBeginBenign(SQLITE_FAULTINJECTOR_MALLOC);
for(i=0; i<db->nDb; i++){
Btree *pBt = db->aDb[i].pBt;
if( pBt ){
sqlite3BtreeCommitPhaseTwo(pBt);
}
}
sqlite3FaultBenign(SQLITE_FAULTINJECTOR_MALLOC, 0);
sqlite3FaultEndBenign(SQLITE_FAULTINJECTOR_MALLOC);
enable_simulated_io_errors();
sqlite3VtabCommit(db);

View File

@ -13,7 +13,7 @@
# correctly. The emphasis of these tests are the _prepare(), _step() and
# _finalize() calls.
#
# $Id: malloc3.test,v 1.21 2008/05/13 00:58:18 drh Exp $
# $Id: malloc3.test,v 1.22 2008/05/13 13:27:34 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -586,7 +586,7 @@ if {$iterid=="pc=4.iFail=44-sql"} breakpoint
# Otherwise a malloc() failed and the error was not reported.
#
if {$nFail!=$nBenign} {
# error "Unreported malloc() failure"
error "Unreported malloc() failure"
}
if {$ac && !$nac} {