-C Do\snot\sreset\sthe\spage\scache\swhen\sa\srollback\sjournal\struncate\sfails,\sas\sdoing\nso\scan\scause\sloss\sof\sinformation\sfor\san\sin-memory\sTEMP\sfile.
-D 2016-05-11T12:47:46.752
+C Remove\ssome\sa\ssmall\samount\sof\sredundant\scode\srelated\sto\sPCache.pSynced\sfrom\spcache.c.
+D 2016-05-11T15:41:15.317
F Makefile.in 9eda6e1c90d05c199c3ec8a7069b0682ad307657
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc db82b35aef27f412fef14d8534afc022138bcdfd
F src/pager.c cb7a3990eabd895f6487c0856a7fec02b5e40faa
F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681
F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e
-F src/pcache.c c128cafaac069e94931c3a743d5cf3d0c7b760d6
+F src/pcache.c 4af980bc2a987cf81ddbe867d238c9ccdbaac95c
F src/pcache.h 6b865be765d1ebd06145219550b10921c7da7cc9
F src/pcache1.c 7f51d2b541aab57596adf62db2c4bb025d34f04d
F src/pragma.c faf42922bb7ab2f6672cb550356c1967abae3c84
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 42fb6f1e99a6c31889819a0302679d598dc0ab1b
-R 6af21f51682f416bafd722831c805292
-U drh
-Z f092752ae332e4cfbb76f62bab02296e
+P 345ce1c9f64f2a424663b4dfcbe4586d9df7bff6
+R 410857f6cadf18a1818aed66391afc72
+U dan
+Z b239392669bc1d86adff0f06ee03f5ae
/*
** A complete page cache is an instance of this structure.
+**
+** pDirty, pDirtyTail, pSynced:
+** All dirty pages are linked into the doubly linked list using
+** PgHdr.pDirtyNext and pDirtyPrev. The list is maintained in LRU order
+** such that p was added to the list more recently than p->pDirtyNext.
+** PCache.pDirty points to the first (newest) element in the list and
+** pDirtyTail to the last (oldest).
+**
+** The PCache.pSynced variable is used to optimize searching for a dirty
+** page to eject from the cache mid-transaction. It is better to eject
+** a page that does not require a journal sync than one that does.
+** Therefore, pSynced is maintained to that it *almost* always points
+** to either the oldest page in the pDirty/pDirtyTail list that has a
+** clear PGHDR_NEED_SYNC flag or to a page that is older than this one
+** (so that the right page to eject can be found by following pDirtyPrev
+** pointers).
*/
struct PCache {
PgHdr *pDirty, *pDirtyTail; /* List of dirty pages in LRU order */
/* Update the PCache1.pSynced variable if necessary. */
if( p->pSynced==pPage ){
- PgHdr *pSynced = pPage->pDirtyPrev;
- while( pSynced && (pSynced->flags&PGHDR_NEED_SYNC) ){
- pSynced = pSynced->pDirtyPrev;
- }
- p->pSynced = pSynced;
+ p->pSynced = pPage->pDirtyPrev;
}
if( pPage->pDirtyNext ){
** page that does not require a journal-sync (one with PGHDR_NEED_SYNC
** cleared), but if that is not possible settle for any other
** unreferenced dirty page.
- */
+ **
+ ** If the LRU page in the dirty list that has a clear PGHDR_NEED_SYNC
+ ** flag is currently referenced, then the following may leave pSynced
+ ** set incorrectly (pointing to other than the LRU page with NEED_SYNC
+ ** cleared). This is Ok, as pSynced is just an optimization. */
for(pPg=pCache->pSynced;
pPg && (pPg->nRef || (pPg->flags&PGHDR_NEED_SYNC));
pPg=pPg->pDirtyPrev