Skip to content

Commit f0f025b

Browse files
author
drh
committed
More assert() statements in the page cache.
FossilOrigin-Name: 7c96a56c0d1de966844da6c5a84c0cd6066130a10724797ce6f228a9182d9b85
1 parent f6e3e31 commit f0f025b

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

manifest

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
C Ensure\sthat\severy\spcache\spage\salways\shas\seither\sthe\sPGHDR_DIRTY\sor\sthe\nPGHDR_CLEAN\sbit\sset,\seven\sduring\stransient\spage\sreshuffling\sduring\sbtree\nbalancing.
2-
D 2022-08-27T14:43:34.272
1+
C More\sassert()\sstatements\sin\sthe\spage\scache.
2+
D 2022-08-27T16:11:00.802
33
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
44
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
55
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -578,7 +578,7 @@ F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
578578
F src/pager.c c60031c483960660853dfecf14c8e830503baab1f638ac997f0144f1bd3e1781
579579
F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3
580580
F src/parse.y 8e67d820030d2655b9942ffe61c1e7e6b96cea2f2f72183533299393907d0564
581-
F src/pcache.c e82ef04f65c0d8c28648f79be10b5ed28f4c5e1b887e21364b09a290109bfdba
581+
F src/pcache.c 5a64e084260560910d9a61bc0e760394fa88aaa22201477ab3e49e278db92edb
582582
F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586
583583
F src/pcache1.c 0b4245cd4964e635f2630908c2533cd8e9da7af3ca592e23ae8730aa25ae5eb9
584584
F src/pragma.c b57a859a366472131194a9ad35cd76d5920577226b04c884b1b9085605faa280
@@ -1999,8 +1999,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
19991999
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
20002000
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
20012001
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
2002-
P c72756b0f2db30c622f00f43be9245d50e36049bd7740ee6332164f0c48f9c3d
2003-
R ec0ec294ce77eea8b112655cdb3d953c
2002+
P e67f03c166277951725c194674c84da61c152a5820aa6df55a726f7dda838e92
2003+
R c207204f107e850d8e2aa83942d0fc9c
20042004
U drh
2005-
Z ddf747439ae76e336531030fc778367f
2005+
Z 3df13e569c05286e45e508a55914ef8f
20062006
# Remove this line to create a well-formed Fossil manifest.

manifest.uuid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e67f03c166277951725c194674c84da61c152a5820aa6df55a726f7dda838e92
1+
7c96a56c0d1de966844da6c5a84c0cd6066130a10724797ce6f228a9182d9b85

src/pcache.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,20 @@ struct PCache {
100100
# define pcacheDump(X)
101101
#endif
102102

103+
/*
104+
** Return 1 if pPg is on the dirty list for pCache. Return 0 if not.
105+
** This routine runs inside of assert() statements only.
106+
*/
107+
#ifdef SQLITE_DEBUG
108+
static int pageOnDirtyList(PCache *pCache, PgHdr *pPg){
109+
PgHdr *p;
110+
for(p=pCache->pDirty; p; p=p->pDirtyNext){
111+
if( p==pPg ) return 1;
112+
}
113+
return 0;
114+
}
115+
#endif
116+
103117
/*
104118
** Check invariants on a PgHdr entry. Return true if everything is OK.
105119
** Return false if any invariant is violated.
@@ -118,13 +132,13 @@ int sqlite3PcachePageSanity(PgHdr *pPg){
118132
assert( pCache!=0 ); /* Every page has an associated PCache */
119133
if( pPg->flags & PGHDR_CLEAN ){
120134
assert( (pPg->flags & PGHDR_DIRTY)==0 );/* Cannot be both CLEAN and DIRTY */
121-
assert( pCache->pDirty!=pPg ); /* CLEAN pages not on dirty list */
122-
assert( pCache->pDirtyTail!=pPg );
135+
assert( !pageOnDirtyList(pCache, pPg) );/* CLEAN pages not on dirty list */
123136
}else{
124137
assert( (pPg->flags & PGHDR_DIRTY)!=0 );/* If not CLEAN must be DIRTY */
125138
assert( pPg->pDirtyNext==0 || pPg->pDirtyNext->pDirtyPrev==pPg );
126139
assert( pPg->pDirtyPrev==0 || pPg->pDirtyPrev->pDirtyNext==pPg );
127140
assert( pPg->pDirtyPrev!=0 || pCache->pDirty==pPg );
141+
assert( pageOnDirtyList(pCache, pPg) );
128142
}
129143
/* WRITEABLE pages must also be DIRTY */
130144
if( pPg->flags & PGHDR_WRITEABLE ){
@@ -528,6 +542,7 @@ void SQLITE_NOINLINE sqlite3PcacheRelease(PgHdr *p){
528542
pcacheUnpin(p);
529543
}else{
530544
pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT);
545+
assert( sqlite3PcachePageSanity(p) );
531546
}
532547
}
533548
}
@@ -571,6 +586,7 @@ void sqlite3PcacheMakeDirty(PgHdr *p){
571586
pcacheTrace(("%p.DIRTY %d\n",p->pCache,p->pgno));
572587
assert( (p->flags & (PGHDR_DIRTY|PGHDR_CLEAN))==PGHDR_DIRTY );
573588
pcacheManageDirtyList(p, PCACHE_DIRTYLIST_ADD);
589+
assert( sqlite3PcachePageSanity(p) );
574590
}
575591
assert( sqlite3PcachePageSanity(p) );
576592
}
@@ -641,6 +657,7 @@ void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){
641657
p->pgno = newPgno;
642658
if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){
643659
pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT);
660+
assert( sqlite3PcachePageSanity(p) );
644661
}
645662
}
646663

0 commit comments

Comments
 (0)