1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Revert to allowing a cache spill during writes of multiple pages within a

single sector as long as the spill does not require a journal sync and a
new journal header.

FossilOrigin-Name: 7d83fbae9802a56b2121d0775de54fccd743d971
This commit is contained in:
drh
2010-06-24 18:36:33 +00:00
parent cfa800cb36
commit 314f30db22
3 changed files with 45 additions and 27 deletions

View File

@@ -1,5 +1,8 @@
C Modify\sctime.test\sto\swork\swith\sSQLITE_THREADSAFE=2.
D 2010-06-24T17:37:57
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Revert\sto\sallowing\sa\scache\sspill\sduring\swrites\sof\smultiple\spages\swithin\sa\nsingle\ssector\sas\slong\sas\sthe\sspill\sdoes\snot\srequire\sa\sjournal\ssync\sand\sa\nnew\sjournal\sheader.
D 2010-06-24T18:36:33
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -156,7 +159,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
F src/os_os2.c 665876d5eec7585226b0a1cf5e18098de2b2da19
F src/os_unix.c 4b03e5a8a353b51af64ba11ffec85160818b4d89
F src/os_win.c 00385a839d54f951a73ceb98ddea29112adea05c
F src/pager.c 24a9be67a52fb5837be4d0319904a273164dee3a
F src/pager.c edf1f8b02b5c106bd3a3add0d06f28859195a0f8
F src/pager.h 879fdde5a102d2f21a3135d6f647530b21c2796c
F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e
F src/pcache.c 1e9aa2dbc0845b52e1b51cc39753b6d1e041cb07
@@ -825,7 +828,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P a55eb4c3e9fa4ea43b8f8182eb9e39138df03f52
R 33ec6ea9feaffcac3eb447f2441d1f63
U dan
Z d4c71ec23bd0a529a8826dcf174b6d9d
P c6db3b303182202a8b03512e448607bce71de914
R f1c7e6ef66554c4040e7c5982474605c
U drh
Z f3f5cfd0105de6cc2c8193ae310c7e35
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFMI6W0oxKgR168RlERAqk4AJ0SrngwAq/5OolSGMdQDkM2Ln5jRQCfZFUX
PXAYzrwwDBWQ+R1Wsf747GA=
=Xijo
-----END PGP SIGNATURE-----

View File

@@ -1 +1 @@
c6db3b303182202a8b03512e448607bce71de914
7d83fbae9802a56b2121d0775de54fccd743d971

View File

@@ -305,13 +305,15 @@ struct PagerSavepoint {
** master journal name is only written to the journal file the first
** time CommitPhaseOne() is called.
**
** doNotSpill
** doNotSpill, doNotSyncSpill
**
** When enabled, cache spills are prohibited and the journal file cannot
** be synced. This variable is set and cleared by sqlite3PagerWrite()
** in order to prevent a journal sync from happening in between the
** journalling of two pages on the same sector. It is also set to prevent
** pagerStress() from trying to use the journal during a rollback.
** When enabled, cache spills are prohibited. The doNotSpill variable
** inhibits all cache spill and doNotSyncSpill inhibits those spills that
** would require a journal sync. The doNotSyncSpill is set and cleared
** by sqlite3PagerWrite() in order to prevent a journal sync from happening
** in between the journalling of two pages on the same sector. The
** doNotSpill value set to prevent pagerStress() from trying to use
** the journal during a rollback.
**
** needSync
**
@@ -356,6 +358,7 @@ struct Pager {
u8 changeCountDone; /* Set after incrementing the change-counter */
u8 setMaster; /* True if a m-j name has been written to jrnl */
u8 doNotSpill; /* Do not spill the cache when non-zero */
u8 doNotSyncSpill; /* Do not do a spill that requires jrnl sync */
u8 dbSizeValid; /* Set when dbSize is correct */
u8 subjInMemory; /* True to use in-memory sub-journals */
Pgno dbSize; /* Number of pages in the database */
@@ -3518,15 +3521,19 @@ static int pagerStress(void *p, PgHdr *pPg){
assert( pPg->pPager==pPager );
assert( pPg->flags&PGHDR_DIRTY );
/* The doNotSpill flag is set during times when writing to the journal
** is disallowed: (1) during calls to sqlite3PagerWrite() while it
** is journalling a set of two or more database pages that are stored
** on the same disk sector, and (2) while performing a rollback.
/* The doNotSyncSpill flag is set during times when doing a sync of
** journal (and adding a new header) is not allowed. This occurs
** during calls to sqlite3PagerWrite() while trying to journal multiple
** pages belonging to the same sector.
**
** Similarly, if the pager has already entered the error state, do not
** try to write the contents of pPg to disk.
** The doNotSpill flag inhibits all cache spilling regardless of whether
** or not a sync is required. This is set during a rollback.
**
** Spilling is also inhibited when in an error state.
*/
if( pPager->errCode || pPager->doNotSpill ){
if( pPager->errCode ) return SQLITE_OK;
if( pPager->doNotSpill ) return SQLITE_OK;
if( pPager->doNotSyncSpill && (pPg->flags & PGHDR_NEED_SYNC)!=0 ){
return SQLITE_OK;
}
@@ -4834,12 +4841,13 @@ int sqlite3PagerWrite(DbPage *pDbPage){
int ii; /* Loop counter */
int needSync = 0; /* True if any page has PGHDR_NEED_SYNC */
/* Set the doNotSpill flag to 1. This is because we cannot allow a journal
** header to be written between the pages journaled by this function.
/* Set the doNotSyncSpill flag to 1. This is because we cannot allow
** a journal header to be written between the pages journaled by
** this function.
*/
assert( !MEMDB );
assert( pPager->doNotSpill==0 );
pPager->doNotSpill++;
assert( pPager->doNotSyncSpill==0 );
pPager->doNotSyncSpill++;
/* This trick assumes that both the page-size and sector-size are
** an integer power of 2. It sets variable pg1 to the identifier
@@ -4901,8 +4909,8 @@ int sqlite3PagerWrite(DbPage *pDbPage){
assert(pPager->needSync);
}
assert( pPager->doNotSpill==1 );
pPager->doNotSpill--;
assert( pPager->doNotSyncSpill==1 );
pPager->doNotSyncSpill--;
}else{
rc = pager_write(pDbPage);
}