Fix a problem with checkpointing large log files created by an external process.

FossilOrigin-Name: 8f94bde568be52ecc5a976b7a09776ea7b4bb511
This commit is contained in:
dan 2010-05-07 06:59:08 +00:00
parent 846705021d
commit 998ad21271
4 changed files with 74 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Since\swalIndexTryHdr()\scan\sno\slonger\sencounter\sany\serror\sconditions,\schange\stehe\sfunction\ssignature\sso\sthat\sit\sdoes\snot\sreturn\san\serror\scode.\sThis\sremoves\sunreachable\sbranches\sfrom\sother\scode.
D 2010-05-07T05:46:23
C Fix\sa\sproblem\swith\scheckpointing\slarge\slog\sfiles\screated\sby\san\sexternal\sprocess.
D 2010-05-07T06:59:09
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -224,7 +224,7 @@ F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e
F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1
F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda
F src/wal.c 57ff825325efeaae5ee86afe6123c96e0ce3478f
F src/wal.c 5321afde90f0819655040d1ca477f3fec9ebefbe
F src/wal.h b4c42014b5fa3b4e6244ac8c65de7ff67adeb27c
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
F src/where.c 75fee9e255b62f773fcadd1d1f25b6f63ac7a356
@ -761,7 +761,7 @@ F test/vtabE.test 7c4693638d7797ce2eda17af74292b97e705cc61
F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d
F test/wal.test f0b78497bbe2e7f3c35a1c28e9772fe0dead1fc8
F test/wal.test 45fd4e9e8f871f38c801fecbf341528710edbfe1
F test/wal2.test 0f53c711d6530d3c7aba46752aef9fd44b708c6c
F test/walbak.test a0e45187c7d8928df035dfea29b99b016b21ca3c
F test/walcrash.test f6d5fb2bb108876f04848720a488065d9deef69f
@ -813,7 +813,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 58c404429c5af167a82899fc4c736ed7489ed746
R f702fd587e74658c827b1251866de967
P 061a282cc0bf76541ab1f99b351a49d489ff93ec
R 3e2d9c06dafc1b5b325ac114ce5c4263
U dan
Z a77a8ab020b2cdace690a5e1ff4f0423
Z a88a95664c9a9b9b2d9abf67515be3e6

View File

@ -1 +1 @@
061a282cc0bf76541ab1f99b351a49d489ff93ec
8f94bde568be52ecc5a976b7a09776ea7b4bb511

View File

@ -398,12 +398,11 @@ static void walIndexUnmap(Wal *pWal){
** Map the wal-index file into memory if it isn't already.
**
** The reqSize parameter is the minimum required size of the mapping.
** A value of -1 means "don't care". The reqSize parameter is ignored
** if the mapping is already held.
** A value of -1 means "don't care".
*/
static int walIndexMap(Wal *pWal, int reqSize){
int rc = SQLITE_OK;
if( pWal->pWiData==0 ){
if( pWal->pWiData==0 || reqSize>pWal->szWIndex ){
rc = pWal->pVfs->xShmGet(pWal->pVfs, pWal->pWIndex, reqSize,
&pWal->szWIndex, (void**)(char*)&pWal->pWiData);
if( rc==SQLITE_OK && pWal->pWiData==0 ){

View File

@ -58,6 +58,7 @@ proc log_deleted {logfile} {
# wal-5.*: Test the temp database.
# wal-6.*: Test creating databases with different page sizes.
#
#
do_test wal-0.1 {
execsql { PRAGMA synchronous = normal }
@ -1398,6 +1399,69 @@ do_test wal-19.4 {
execsql { SELECT * FROM t1 }
} {1 2 3 4 5 6}
#-------------------------------------------------------------------------
# This test - wal-20.* - uses two connections. One in this process and
# the other in an external process. The procedure is:
#
# 1. Using connection 1, create the database schema.
#
# 2. Using connection 2 (in an external process), add so much
# data to the database without checkpointing that a wal-index
# larger than 64KB is required.
#
# 3. Using connection 1, checkpoint the database. Make sure all
# the data is present and the database is not corrupt.
#
# At one point, SQLite was failing to grow the mapping of the wal-index
# file in step 3 and the checkpoint was corrupting the database file.
#
do_test wal-20.1 {
file delete -force test.db test.db-wal test.db-journal
sqlite3 db test.db
execsql {
PRAGMA journal_mode = WAL;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(randomblob(900));
SELECT count(*) FROM t1;
}
} {wal 1}
do_test wal-20.2 {
set ::buddy [launch_testfixture]
testfixture $::buddy {
sqlite3 db test.db
db transaction { db eval {
PRAGMA wal_autocheckpoint = 0;
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 2 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 8 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 16 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 32 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 64 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 128 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 256 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 512 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 1024 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 2048 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4096 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 8192 */
INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 16384 */
} }
}
} {0}
do_test wal-20.3 {
close $::buddy
execsql {
PRAGMA wal_checkpoint;
SELECT count(*) FROM t1;
}
} {16384}
do_test wal-20.4 {
db close
sqlite3 db test.db
execsql { SELECT count(*) FROM t1 }
} {16384}
integrity_check wal-20.5
catch { db2 close }
catch { db close }