mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Additional changes in the pager and os interface layers to fix problems that
might be contributing to recently observed database corruption. (CVS 3549) FossilOrigin-Name: a593d5743eab12c0f93a7bc436f0d69dfab0c387
This commit is contained in:
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Make\ssure\sthat\sthe\sdatabase\ssize\scache\sin\sthe\spager\sis\sinvalidated\swhenever\nthe\sdatabase\sis\sunlocked.\s\sA\sstale\svalue\sin\sthe\sdatabase\ssize\scache\scan\nresult\sin\sdatabase\scorruption\son\sa\sheavily\sloaded\ssystem\srunning\nautovacuum.\s(CVS\s3548)
|
C Additional\schanges\sin\sthe\spager\sand\sos\sinterface\slayers\sto\sfix\sproblems\sthat\nmight\sbe\scontributing\sto\srecently\sobserved\sdatabase\scorruption.\s(CVS\s3549)
|
||||||
D 2007-01-03T15:34:30
|
D 2007-01-03T23:36:22
|
||||||
F Makefile.in 63a71177ed4355c829229affe11167bd28c85884
|
F Makefile.in 63a71177ed4355c829229affe11167bd28c85884
|
||||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -81,11 +81,11 @@ F src/os_os2.c 1ece434c4817e2925318954336cfe1731713beb0
|
|||||||
F src/os_os2.h e5f17dd69333632bbc3112881ea407c37d245eb3
|
F src/os_os2.h e5f17dd69333632bbc3112881ea407c37d245eb3
|
||||||
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
|
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
|
||||||
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
|
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
|
||||||
F src/os_unix.c d4bc8cbe1c0dc330bd55bf7821db5b7dbfbf183e
|
F src/os_unix.c 9fbbd8ab0a6b3992370ba0f3aae11feff2a78c96
|
||||||
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
||||||
F src/os_win.c ca46001d4ec446885f72d3b7fd6a657136156228
|
F src/os_win.c 92df146ed964401969831a19bb490d76ce4de4c0
|
||||||
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
||||||
F src/pager.c 4dbd6a12eb43f10a3c870a3006a54a7756768455
|
F src/pager.c 28fdd84dc1f6eaa2ea0754bc88f7e0efd74b9eb9
|
||||||
F src/pager.h 2e6d42f4ae004ae748a037b8468112b851c447a7
|
F src/pager.h 2e6d42f4ae004ae748a037b8468112b851c447a7
|
||||||
F src/parse.y 2f571c5f6219428d7fb08737db3d113742b1cceb
|
F src/parse.y 2f571c5f6219428d7fb08737db3d113742b1cceb
|
||||||
F src/pragma.c d0891d3504b6291b506a5ec2226bbf79ffcef003
|
F src/pragma.c d0891d3504b6291b506a5ec2226bbf79ffcef003
|
||||||
@@ -423,7 +423,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||||
P bf1afd016ad71dac90e58540122108f92e77ce3d
|
P 6806b9ecb5e3b90e793c5862404e76485df33b25
|
||||||
R ffed07664ab99ec35d86454afb31b5e4
|
R 5eb75b3bfe211ed1d7c750440df7692b
|
||||||
U drh
|
U drh
|
||||||
Z 6c9f735d21716c225946d83bfcb229d4
|
Z bcb83f017e9e848c1a261f1dbdf86d77
|
||||||
|
@@ -1 +1 @@
|
|||||||
6806b9ecb5e3b90e793c5862404e76485df33b25
|
a593d5743eab12c0f93a7bc436f0d69dfab0c387
|
@@ -1032,6 +1032,7 @@ static int unixRead(OsFile *id, void *pBuf, int amt){
|
|||||||
}else if( got<0 ){
|
}else if( got<0 ){
|
||||||
return SQLITE_IOERR_READ;
|
return SQLITE_IOERR_READ;
|
||||||
}else{
|
}else{
|
||||||
|
memset(&((char*)pBuf)[got], 0, amt-got);
|
||||||
return SQLITE_IOERR_SHORT_READ;
|
return SQLITE_IOERR_SHORT_READ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1010,6 +1010,7 @@ static int winRead(OsFile *id, void *pBuf, int amt){
|
|||||||
}else if( got<0 ){
|
}else if( got<0 ){
|
||||||
return SQLITE_IOERR_READ;
|
return SQLITE_IOERR_READ;
|
||||||
}else{
|
}else{
|
||||||
|
memset(&((char*)pBuf)[got], 0, amt-got);
|
||||||
return SQLITE_IOERR_SHORT_READ;
|
return SQLITE_IOERR_SHORT_READ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
43
src/pager.c
43
src/pager.c
@@ -18,7 +18,7 @@
|
|||||||
** file simultaneously, or one process from reading the database while
|
** file simultaneously, or one process from reading the database while
|
||||||
** another is writing.
|
** another is writing.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pager.c,v 1.279 2007/01/03 15:34:30 drh Exp $
|
** @(#) $Id: pager.c,v 1.280 2007/01/03 23:36:22 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE_OMIT_DISKIO
|
#ifndef SQLITE_OMIT_DISKIO
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -863,6 +863,7 @@ static void pager_unlock(Pager *pPager){
|
|||||||
pPager->dbSize = -1;
|
pPager->dbSize = -1;
|
||||||
}
|
}
|
||||||
pPager->state = PAGER_UNLOCK;
|
pPager->state = PAGER_UNLOCK;
|
||||||
|
assert( pPager->pAll==0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -892,7 +893,7 @@ static void pager_reset(Pager *pPager){
|
|||||||
}
|
}
|
||||||
pager_unlock(pPager);
|
pager_unlock(pPager);
|
||||||
pPager->nRef = 0;
|
pPager->nRef = 0;
|
||||||
assert( pPager->journalOpen==0 );
|
assert( pPager->errCode || (pPager->journalOpen==0 && pPager->stmtOpen==0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2063,7 +2064,6 @@ int sqlite3pager_truncate(Pager *pPager, Pgno nPage){
|
|||||||
** to the caller.
|
** to the caller.
|
||||||
*/
|
*/
|
||||||
int sqlite3pager_close(Pager *pPager){
|
int sqlite3pager_close(Pager *pPager){
|
||||||
PgHdr *pPg, *pNext;
|
|
||||||
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
|
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
|
||||||
/* A malloc() cannot fail in sqlite3ThreadData() as one or more calls to
|
/* A malloc() cannot fail in sqlite3ThreadData() as one or more calls to
|
||||||
** malloc() must have already been made by this thread before it gets
|
** malloc() must have already been made by this thread before it gets
|
||||||
@@ -2075,42 +2075,9 @@ int sqlite3pager_close(Pager *pPager){
|
|||||||
assert( pTsd && pTsd->nAlloc );
|
assert( pTsd && pTsd->nAlloc );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch( pPager->state ){
|
|
||||||
case PAGER_RESERVED:
|
|
||||||
case PAGER_SYNCED:
|
|
||||||
case PAGER_EXCLUSIVE: {
|
|
||||||
/* We ignore any IO errors that occur during the rollback
|
|
||||||
** operation. So disable IO error simulation so that testing
|
|
||||||
** works more easily.
|
|
||||||
*/
|
|
||||||
disable_simulated_io_errors();
|
disable_simulated_io_errors();
|
||||||
sqlite3pager_rollback(pPager);
|
pager_reset(pPager);
|
||||||
enable_simulated_io_errors();
|
enable_simulated_io_errors();
|
||||||
pager_unlock(pPager);
|
|
||||||
assert( pPager->errCode || pPager->journalOpen==0 );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PAGER_SHARED: {
|
|
||||||
pager_unlock(pPager);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
/* Do nothing */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(pPg=pPager->pAll; pPg; pPg=pNext){
|
|
||||||
#ifndef NDEBUG
|
|
||||||
if( MEMDB ){
|
|
||||||
PgHistory *pHist = PGHDR_TO_HIST(pPg, pPager);
|
|
||||||
assert( !pPg->alwaysRollback );
|
|
||||||
assert( !pHist->pOrig );
|
|
||||||
assert( !pHist->pStmt );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
pNext = pPg->pNextAll;
|
|
||||||
sqliteFree(pPg);
|
|
||||||
}
|
|
||||||
TRACE2("CLOSE %d\n", PAGERID(pPager));
|
TRACE2("CLOSE %d\n", PAGERID(pPager));
|
||||||
assert( pPager->errCode || (pPager->journalOpen==0 && pPager->stmtOpen==0) );
|
assert( pPager->errCode || (pPager->journalOpen==0 && pPager->stmtOpen==0) );
|
||||||
if( pPager->journalOpen ){
|
if( pPager->journalOpen ){
|
||||||
@@ -2989,7 +2956,7 @@ failed_to_open_journal:
|
|||||||
*/
|
*/
|
||||||
sqlite3OsDelete(pPager->zJournal);
|
sqlite3OsDelete(pPager->zJournal);
|
||||||
}else{
|
}else{
|
||||||
pager_unlock(pPager);
|
pager_reset(pPager);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user