Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add a HIGHSTRESS parameter to the sqlite3_config_alt_pcache debugging command in the test harness - to force calling pagerStress() more frequently. (CVS 6127) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e426860b94f5b47e3a265549dbac64a4 |
User & Date: | drh 2009-01-07 03:59:47.000 |
Context
2009-01-07
| ||
08:12 | Fix savepoint related bugs. A rollback caused by an IO error or "OR ROLLBACK" clause while one or more savepoints were open was leaving the sqlite3 structure in an invalid state. (CVS 6128) (check-in: e5d42c69a3 user: danielk1977 tags: trunk) | |
03:59 | Add a HIGHSTRESS parameter to the sqlite3_config_alt_pcache debugging command in the test harness - to force calling pagerStress() more frequently. (CVS 6127) (check-in: e426860b94 user: drh tags: trunk) | |
02:03 | Pager changes attempting to verify that ticket #2565 cannot recur. (CVS 6126) (check-in: 15b9dac455 user: drh tags: trunk) | |
Changes
Changes to src/test_malloc.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains code used to implement test interfaces to the ** memory allocation subsystem. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains code used to implement test interfaces to the ** memory allocation subsystem. ** ** $Id: test_malloc.c,v 1.52 2009/01/07 03:59:47 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> #include <assert.h> |
︙ | ︙ | |||
958 959 960 961 962 963 964 | static int test_alt_pcache( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int installFlag; | | | > | | | > | > > | > > > > > | > | 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 | static int test_alt_pcache( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int installFlag; int discardChance = 0; int prngSeed = 0; int highStress = 0; extern void installTestPCache(int,unsigned,unsigned,unsigned); if( objc<2 || objc>5 ){ Tcl_WrongNumArgs(interp, 1, objv, "INSTALLFLAG DISCARDCHANCE PRNGSEEED HIGHSTRESS"); return TCL_ERROR; } if( Tcl_GetIntFromObj(interp, objv[1], &installFlag) ) return TCL_ERROR; if( objc>=3 && Tcl_GetIntFromObj(interp, objv[2], &discardChance) ){ return TCL_ERROR; } if( objc>=4 && Tcl_GetIntFromObj(interp, objv[3], &prngSeed) ){ return TCL_ERROR; } if( objc>=5 && Tcl_GetIntFromObj(interp, objv[4], &highStress) ){ return TCL_ERROR; } if( discardChance<0 || discardChance>100 ){ Tcl_AppendResult(interp, "discard-chance should be between 0 and 100", (char*)0); return TCL_ERROR; } installTestPCache(installFlag, (unsigned)discardChance, (unsigned)prngSeed, (unsigned)highStress); return TCL_OK; } /* ** Usage: sqlite3_config_memstatus BOOLEAN ** ** Enable or disable memory status reporting using SQLITE_CONFIG_MEMSTATUS. |
︙ | ︙ |
Changes to src/test_pcache.c.
︙ | ︙ | |||
17 18 19 20 21 22 23 | ** implementation that can be plugged in in place of the ** default pcache. This alternative pager cache will throw ** some errors that the default cache does not. ** ** This pagecache implementation is designed for simplicity ** not speed. ** | | | > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | ** implementation that can be plugged in in place of the ** default pcache. This alternative pager cache will throw ** some errors that the default cache does not. ** ** This pagecache implementation is designed for simplicity ** not speed. ** ** $Id: test_pcache.c,v 1.2 2009/01/07 03:59:47 drh Exp $ */ #include "sqlite3.h" #include <string.h> #include <assert.h> /* ** Global data used by this test implementation. There is no ** mutexing, which means this page cache will not work in a ** multi-threaded test. */ typedef struct testpcacheGlobalType testpcacheGlobalType; struct testpcacheGlobalType { void *pDummy; /* Dummy allocation to simulate failures */ int nInstance; /* Number of current instances */ unsigned discardChance; /* Chance of discarding on an unpin (0-100) */ unsigned prngSeed; /* Seed for the PRNG */ unsigned highStress; /* Call xStress agressively */ }; static testpcacheGlobalType testpcacheGlobal; /* ** Initializer. ** ** Verify that the initializer is only called when the system is |
︙ | ︙ | |||
205 206 207 208 209 210 211 212 213 214 215 216 217 218 | return 0; } /* Do not allocate the last TESTPCACHE_RESERVE pages unless createFlag is 2 */ if( p->nPinned>=TESTPCACHE_NPAGE-TESTPCACHE_RESERVE && createFlag<2 ){ return 0; } /* Find a free page to allocate if there are any free pages. ** Withhold TESTPCACHE_RESERVE free pages until createFlag is 2. */ if( p->nFree>TESTPCACHE_RESERVE || (createFlag==2 && p->nFree>0) ){ j = testpcacheRandom(p) % TESTPCACHE_NPAGE; for(i=0; i<TESTPCACHE_NPAGE; i++, j = (j+1)%TESTPCACHE_NPAGE){ | > > > > > > > > > | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | return 0; } /* Do not allocate the last TESTPCACHE_RESERVE pages unless createFlag is 2 */ if( p->nPinned>=TESTPCACHE_NPAGE-TESTPCACHE_RESERVE && createFlag<2 ){ return 0; } /* Do not allocate if highStress is enabled and createFlag is not 2. ** ** The highStress setting causes pagerStress() to be called much more ** often, which exercises the pager logic more intensely. */ if( testpcacheGlobal.highStress && createFlag<2 ){ return 0; } /* Find a free page to allocate if there are any free pages. ** Withhold TESTPCACHE_RESERVE free pages until createFlag is 2. */ if( p->nFree>TESTPCACHE_RESERVE || (createFlag==2 && p->nFree>0) ){ j = testpcacheRandom(p) % TESTPCACHE_NPAGE; for(i=0; i<TESTPCACHE_NPAGE; i++, j = (j+1)%TESTPCACHE_NPAGE){ |
︙ | ︙ | |||
397 398 399 400 401 402 403 | ** indicates the probability of discarding a page when unpinning the ** page. 0 means never discard (unless the discard flag is set). ** 100 means always discard. */ void installTestPCache( int installFlag, /* True to install. False to uninstall. */ unsigned discardChance, /* 0-100. Chance to discard on unpin */ | | > | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | ** indicates the probability of discarding a page when unpinning the ** page. 0 means never discard (unless the discard flag is set). ** 100 means always discard. */ void installTestPCache( int installFlag, /* True to install. False to uninstall. */ unsigned discardChance, /* 0-100. Chance to discard on unpin */ unsigned prngSeed, /* Seed for the PRNG */ unsigned highStress /* Call xStress agressively */ ){ static const sqlite3_pcache_methods testPcache = { (void*)&testpcacheGlobal, testpcacheInit, testpcacheShutdown, testpcacheCreate, testpcacheCachesize, |
︙ | ︙ | |||
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | static int isInstalled = 0; assert( testpcacheGlobal.nInstance==0 ); assert( testpcacheGlobal.pDummy==0 ); assert( discardChance<=100 ); testpcacheGlobal.discardChance = discardChance; testpcacheGlobal.prngSeed = prngSeed ^ (prngSeed<<16); if( installFlag!=isInstalled ){ if( installFlag ){ sqlite3_config(SQLITE_CONFIG_GETPCACHE, &defaultPcache); assert( defaultPcache.xCreate!=testpcacheCreate ); sqlite3_config(SQLITE_CONFIG_PCACHE, &testPcache); }else{ assert( defaultPcache.xCreate!=0 ); sqlite3_config(SQLITE_CONFIG_PCACHE, &defaultPcache); } isInstalled = installFlag; } } | > | 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | static int isInstalled = 0; assert( testpcacheGlobal.nInstance==0 ); assert( testpcacheGlobal.pDummy==0 ); assert( discardChance<=100 ); testpcacheGlobal.discardChance = discardChance; testpcacheGlobal.prngSeed = prngSeed ^ (prngSeed<<16); testpcacheGlobal.highStress = highStress; if( installFlag!=isInstalled ){ if( installFlag ){ sqlite3_config(SQLITE_CONFIG_GETPCACHE, &defaultPcache); assert( defaultPcache.xCreate!=testpcacheCreate ); sqlite3_config(SQLITE_CONFIG_PCACHE, &testPcache); }else{ assert( defaultPcache.xCreate!=0 ); sqlite3_config(SQLITE_CONFIG_PCACHE, &defaultPcache); } isInstalled = installFlag; } } |