Fix another RBU case similar to the previous. This one for systems where the
sector-size is larger than the page-size. FossilOrigin-Name: 4012bb3aa91927156ba149caa4e5c622b0729d79
This commit is contained in:
parent
cb1b0a693a
commit
1d62a66230
@ -45,7 +45,12 @@ db_save_and_close
|
||||
|
||||
proc do_rbu_crash_test2 {tn script} {
|
||||
|
||||
foreach f {test.db test.db2} {
|
||||
foreach {f blksz} {
|
||||
test.db 512
|
||||
test.db2 512
|
||||
test.db 4096
|
||||
test.db2 4096
|
||||
} {
|
||||
set bDone 0
|
||||
for {set iDelay 1} {$bDone==0} {incr iDelay} {
|
||||
forcedelete test.db2 test.db2-journal test.db test.db-oal test.db-wal
|
||||
@ -53,7 +58,7 @@ proc do_rbu_crash_test2 {tn script} {
|
||||
|
||||
set res [
|
||||
crashsql -file $f -delay $iDelay -tclbody $script -dflt 1 -opendb {} \
|
||||
-blocksize 512 {}
|
||||
-blocksize $blksz {}
|
||||
]
|
||||
|
||||
set bDone 1
|
||||
@ -68,7 +73,7 @@ proc do_rbu_crash_test2 {tn script} {
|
||||
rbu close
|
||||
|
||||
sqlite3 db test.db
|
||||
do_execsql_test $tn.delay=$iDelay.f=$f {
|
||||
do_execsql_test $tn.delay=$iDelay.f=$f.blksz=$blksz {
|
||||
PRAGMA integrity_check;
|
||||
} {ok}
|
||||
db close
|
||||
|
@ -40,6 +40,7 @@ proc create_rbu1 {filename} {
|
||||
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
PRAGMA page_size = 4096;
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
|
||||
}
|
||||
|
||||
@ -266,6 +267,7 @@ foreach bReopen {0 1} {
|
||||
do_test 3.$bReopen.1.0 {
|
||||
reset_db
|
||||
execsql {
|
||||
PRAGMA page_size = 4096;
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
|
||||
CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
|
||||
CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
|
||||
|
@ -356,6 +356,7 @@ struct sqlite3rbu {
|
||||
RbuObjIter objiter; /* Iterator for skipping through tbl/idx */
|
||||
const char *zVfsName; /* Name of automatically created rbu vfs */
|
||||
rbu_file *pTargetFd; /* File handle open on target db */
|
||||
int nPagePerSector; /* Pages per sector for pTargetFd */
|
||||
i64 iOalSz;
|
||||
i64 nPhaseOneStep;
|
||||
|
||||
@ -2620,6 +2621,16 @@ static void rbuSetupCheckpoint(sqlite3rbu *p, RbuState *pState){
|
||||
if( p->nFrame==0 || (pState && pState->iWalCksum!=p->iWalCksum) ){
|
||||
p->rc = SQLITE_DONE;
|
||||
p->eStage = RBU_STAGE_DONE;
|
||||
}else{
|
||||
int nSectorSize;
|
||||
sqlite3_file *pDb = p->pTargetFd->pReal;
|
||||
assert( p->nPagePerSector==0 );
|
||||
nSectorSize = pDb->pMethods->xSectorSize(pDb);
|
||||
if( nSectorSize>p->pgsz ){
|
||||
p->nPagePerSector = nSectorSize / p->pgsz;
|
||||
}else{
|
||||
p->nPagePerSector = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3275,9 +3286,26 @@ int sqlite3rbu_step(sqlite3rbu *p){
|
||||
p->rc = SQLITE_DONE;
|
||||
}
|
||||
}else{
|
||||
/* At one point the following block copied a single frame from the
|
||||
** wal file to the database file. So that one call to sqlite3rbu_step()
|
||||
** checkpointed a single frame.
|
||||
**
|
||||
** However, if the sector-size is larger than the page-size, and the
|
||||
** application calls sqlite3rbu_savestate() or close() immediately
|
||||
** after this step, then rbu_step() again, then a power failure occurs,
|
||||
** then the database page written here may be damaged. Work around
|
||||
** this by checkpointing frames until the next page in the aFrame[]
|
||||
** lies on a different disk sector to the current one. */
|
||||
u32 iSector;
|
||||
do{
|
||||
RbuFrame *pFrame = &p->aFrame[p->nStep];
|
||||
iSector = (pFrame->iDbPage-1) / p->nPagePerSector;
|
||||
rbuCheckpointFrame(p, pFrame);
|
||||
p->nStep++;
|
||||
}while( p->nStep<p->nFrame
|
||||
&& iSector==((p->aFrame[p->nStep].iDbPage-1) / p->nPagePerSector)
|
||||
&& p->rc==SQLITE_OK
|
||||
);
|
||||
}
|
||||
p->nProgress++;
|
||||
}
|
||||
|
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C When\ssaving\sthe\sstate\sof\san\sRBU\supdate\sin\sthe\sincremental-checkpoint\sphase,\nsync\sthe\sdatabase\sfile.\sOtherwise,\sif\sa\spower\sfailure\soccurs\sand\sthe\sRBU\nupdate\sresumed\sfollowing\ssystem\srecovery,\sthe\sdatabase\smay\sbecome\scorrupt.
|
||||
D 2017-03-02T14:51:47.379
|
||||
C Fix\sanother\sRBU\scase\ssimilar\sto\sthe\sprevious.\sThis\sone\sfor\ssystems\swhere\sthe\nsector-size\sis\slarger\sthan\sthe\spage-size.
|
||||
D 2017-03-02T16:56:48.085
|
||||
F Makefile.in edb6bcdd37748d2b1c3422ff727c748df7ffe918
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc a89ea37ab5928026001569f056973b9059492fe2
|
||||
@ -250,7 +250,7 @@ F ext/rbu/rbuB.test c25bc325b8072a766e56bb76c001866b405925c2
|
||||
F ext/rbu/rbuC.test efe47db508a0269b683cb2a1913a425ffd39a831
|
||||
F ext/rbu/rbu_common.tcl a38e8e2d4a50fd6aaf151633714c1b1d2fae3ead
|
||||
F ext/rbu/rbucrash.test 8d2ed5d4b05fef6c00c2a6b5f7ead71fa172a695
|
||||
F ext/rbu/rbucrash2.test 7f3fe5d6d930be0965f27b49bdcdc8d4a078b73c
|
||||
F ext/rbu/rbucrash2.test b2ecbdd7bb72c88bd217c65bd00dafa07f7f2d4d
|
||||
F ext/rbu/rbudiff.test 3e605cf624d00d04d0fb1316a3acec4fbe3b3ac5
|
||||
F ext/rbu/rbudor.test 99b05cc0df613e962c2c8085cfb05686a09cf315
|
||||
F ext/rbu/rbufault.test cc0be8d5d392d98b0c2d6a51be377ea989250a89
|
||||
@ -258,12 +258,12 @@ F ext/rbu/rbufault2.test 9a7f19edd6ea35c4c9f807d8a3db0a03a5670c06
|
||||
F ext/rbu/rbufault3.test 54a399888ac4af44c68f9f58afbed23149428bca
|
||||
F ext/rbu/rbufault4.test 34e70701cbec51571ffbd9fbf9d4e0f2ec495ca7
|
||||
F ext/rbu/rbufts.test 828cd689da825f0a7b7c53ffc1f6f7fdb6fa5bda
|
||||
F ext/rbu/rbuprogress.test e3e25fb7622641b8f2df7c6b7a7eb6fddfc46a4b
|
||||
F ext/rbu/rbuprogress.test 1849d4e0e50616edf5ce75ce7db86622e656b5cf
|
||||
F ext/rbu/rburesume.test 8acb77f4a422ff55acfcfc9cc15a5cb210b1de83
|
||||
F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48
|
||||
F ext/rbu/rbuvacuum.test 4a977447c15c2581ab668781d9ef4294382530e0
|
||||
F ext/rbu/rbuvacuum2.test 2074ab14fe66e1c7e7210c62562650dcd215bbaa
|
||||
F ext/rbu/sqlite3rbu.c 3c2dfd3f27a3ecc5f017ecf82d563b522bbc341a
|
||||
F ext/rbu/sqlite3rbu.c cba23db39792175295b94ad0086825894b617921
|
||||
F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba
|
||||
F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88
|
||||
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
||||
@ -1560,7 +1560,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 29f54b899e5cf22ece98ab41c39c41d75a4b228d
|
||||
R fd6b0917cff6359266006d6c00dd0a12
|
||||
P edee6a80e1cc7e6a2b8c3c7f76dd794fc8ab9a72
|
||||
R f72d0ed562c179232e2d4d139b6c6946
|
||||
U dan
|
||||
Z 1a59570e49a3b7cf84dd8025330375c8
|
||||
Z a85a6fd6f15328765626feb0d9a72fd7
|
||||
|
@ -1 +1 @@
|
||||
edee6a80e1cc7e6a2b8c3c7f76dd794fc8ab9a72
|
||||
4012bb3aa91927156ba149caa4e5c622b0729d79
|
Loading…
Reference in New Issue
Block a user