/ Check-in [9d7722f4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Do not mark pages as clean when doing a statement journal rollback. (CVS 5626)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:9d7722f4f357b96c37f950024f1e7e160e2c1252
User & Date: drh 2008-08-27 18:03:20
Context
2008-08-27
18:56
Add the trans2.test script designed to stress statement rollback and no-write optimizations on large transactions with a small cache. (CVS 5627) check-in: 39c34e22 user: drh tags: trunk
18:03
Do not mark pages as clean when doing a statement journal rollback. (CVS 5626) check-in: 9d7722f4 user: drh tags: trunk
16:38
Modifications to malloc5.test to account for the fact that sqlite3_release_memory() no longer reclaims dirty pages. (CVS 5625) check-in: b01c65b0 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

    14     14   ** The pager is used to access a database disk file.  It implements
    15     15   ** atomic commit and rollback through the use of a journal file that
    16     16   ** is separate from the database file.  The pager also implements file
    17     17   ** locking to prevent two processes from writing the same database
    18     18   ** file simultaneously, or one process from reading the database while
    19     19   ** another is writing.
    20     20   **
    21         -** @(#) $Id: pager.c,v 1.483 2008/08/27 15:16:34 danielk1977 Exp $
           21  +** @(#) $Id: pager.c,v 1.484 2008/08/27 18:03:20 drh Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   
    26     26   /*
    27     27   ** Macros for troubleshooting.  Normally turned off
    28     28   */
................................................................................
  1052   1052   /* Forward declaration */
  1053   1053   static void makeClean(PgHdr*);
  1054   1054   
  1055   1055   /*
  1056   1056   ** Read a single page from the journal file opened on file descriptor
  1057   1057   ** jfd.  Playback this one page.
  1058   1058   **
  1059         -** If useCksum==0 it means this journal does not use checksums.  Checksums
  1060         -** are not used in statement journals because statement journals do not
  1061         -** need to survive power failures.
         1059  +** The isMainJrnl flag is true if this is the main rollback journal and
         1060  +** false for the statement journal.  The main rollback journal uses
         1061  +** checksums - the statement journal does not.
  1062   1062   */
  1063   1063   static int pager_playback_one_page(
  1064         -  Pager *pPager, 
  1065         -  sqlite3_file *jfd,
  1066         -  i64 offset,
  1067         -  int useCksum
         1064  +  Pager *pPager,       /* The pager being played back */
         1065  +  sqlite3_file *jfd,   /* The file that is the journal being rolled back */
         1066  +  i64 offset,          /* Offset of the page within the journal */
         1067  +  int isMainJrnl       /* True for main rollback journal. False for Stmt jrnl */
  1068   1068   ){
  1069   1069     int rc;
  1070   1070     PgHdr *pPg;                   /* An existing page in the cache */
  1071   1071     Pgno pgno;                    /* The page number of a page in journal */
  1072   1072     u32 cksum;                    /* Checksum used for sanity checking */
  1073   1073     u8 *aData = (u8 *)pPager->pTmpSpace;   /* Temp storage for a page */
  1074   1074   
  1075         -  /* useCksum should be true for the main journal and false for
         1075  +  /* isMainJrnl should be true for the main journal and false for
  1076   1076     ** statement journals.  Verify that this is always the case
  1077   1077     */
  1078         -  assert( jfd == (useCksum ? pPager->jfd : pPager->stfd) );
         1078  +  assert( jfd == (isMainJrnl ? pPager->jfd : pPager->stfd) );
  1079   1079     assert( aData );
  1080   1080   
  1081   1081     rc = read32bits(jfd, offset, &pgno);
  1082   1082     if( rc!=SQLITE_OK ) return rc;
  1083   1083     rc = sqlite3OsRead(jfd, aData, pPager->pageSize, offset+4);
  1084   1084     if( rc!=SQLITE_OK ) return rc;
  1085   1085     pPager->journalOff += pPager->pageSize + 4;
................................................................................
  1091   1091     */
  1092   1092     if( pgno==0 || pgno==PAGER_MJ_PGNO(pPager) ){
  1093   1093       return SQLITE_DONE;
  1094   1094     }
  1095   1095     if( pgno>(unsigned)pPager->dbSize ){
  1096   1096       return SQLITE_OK;
  1097   1097     }
  1098         -  if( useCksum ){
         1098  +  if( isMainJrnl ){
  1099   1099       rc = read32bits(jfd, offset+pPager->pageSize+4, &cksum);
  1100   1100       if( rc ) return rc;
  1101   1101       pPager->journalOff += 4;
  1102   1102       if( pager_cksum(pPager, aData)!=cksum ){
  1103   1103         return SQLITE_DONE;
  1104   1104       }
  1105   1105     }
................................................................................
  1152   1152       /* No page should ever be explicitly rolled back that is in use, except
  1153   1153       ** for page 1 which is held in use in order to keep the lock on the
  1154   1154       ** database active. However such a page may be rolled back as a result
  1155   1155       ** of an internal error resulting in an automatic call to
  1156   1156       ** sqlite3PagerRollback().
  1157   1157       */
  1158   1158       void *pData;
  1159         -    /* assert( pPg->nRef==0 || pPg->pgno==1 ); */
  1160   1159       pData = pPg->pData;
  1161   1160       memcpy(pData, aData, pPager->pageSize);
  1162   1161       if( pPager->xReiniter ){
  1163   1162         pPager->xReiniter(pPg, pPager->pageSize);
  1164   1163       }
  1165         -    makeClean(pPg);
         1164  +    if( isMainJrnl ) makeClean(pPg);
  1166   1165   #ifdef SQLITE_CHECK_PAGES
  1167   1166       pPg->pageHash = pager_pagehash(pPg);
  1168   1167   #endif
  1169   1168       /* If this was page 1, then restore the value of Pager.dbFileVers.
  1170   1169       ** Do this before any decoding. */
  1171   1170       if( pgno==1 ){
  1172   1171         memcpy(&pPager->dbFileVers, &((u8*)pData)[24],sizeof(pPager->dbFileVers));