/ Check-in [bb6a75f4]
Login

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

Overview
Comment:Merge the fix for the journal_mode=PERSIST error recovery delay bug.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1: bb6a75f4bbcaaabc3ad47992c7c87868c70e8daf
User & Date: drh 2014-03-07 14:36:50
Context
2014-03-11
01:48
Version 3.8.4 for sessions (plus two minor fixes). check-in: 917c4108 user: drh tags: sessions
2014-03-07
14:36
Merge the fix for the journal_mode=PERSIST error recovery delay bug. check-in: bb6a75f4 user: drh tags: sessions
03:31
Revise change from the previous check-in to clarify the situation when handling open journal files, regardless of journal mode. check-in: 1c318ef3 user: mistachkin tags: trunk
2014-03-06
15:01
Fix a harmless compiler warning in the sessions test harness. check-in: d389e20a user: drh tags: sessions
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

  4885   4885       ** in fact there is none.  This results in a false-positive which will
  4886   4886       ** be dealt with by the playback routine.  Ticket #3883.
  4887   4887       */
  4888   4888       rc = sqlite3OsCheckReservedLock(pPager->fd, &locked);
  4889   4889       if( rc==SQLITE_OK && !locked ){
  4890   4890         Pgno nPage;                 /* Number of pages in database file */
  4891   4891   
  4892         -      /* Check the size of the database file. If it consists of 0 pages,
  4893         -      ** then delete the journal file. See the header comment above for 
  4894         -      ** the reasoning here.  Delete the obsolete journal file under
  4895         -      ** a RESERVED lock to avoid race conditions and to avoid violating
  4896         -      ** [H33020].
         4892  +      /* Check the size of the database file. If it consists of 0 pages
         4893  +      ** and the journal is not being persisted, then delete the journal
         4894  +      ** file.  See the header comment above for the reasoning here.
         4895  +      ** Delete the obsolete journal file under a RESERVED lock to avoid
         4896  +      ** race conditions and to avoid violating [H33020].
  4897   4897         */
  4898   4898         rc = pagerPagecount(pPager, &nPage);
  4899   4899         if( rc==SQLITE_OK ){
  4900         -        if( nPage==0 ){
         4900  +        if( nPage==0 && !jrnlOpen ){
  4901   4901             sqlite3BeginBenignMalloc();
  4902   4902             if( pagerLockDb(pPager, RESERVED_LOCK)==SQLITE_OK ){
  4903   4903               sqlite3OsDelete(pVfs, pPager->zJournal, 0);
  4904   4904               if( !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);
  4905   4905             }
  4906   4906             sqlite3EndBenignMalloc();
  4907   4907           }else{

Changes to test/corruptH.test.

    15     15   set testprefix corruptH
    16     16   
    17     17   # Do not use a codec for tests in this file, as the database file is
    18     18   # manipulated directly using tcl scripts (using the [hexio_write] command).
    19     19   #
    20     20   do_not_use_codec
    21     21   database_may_be_corrupt
           22  +
           23  +# The corruption migrations tested by the code in this file are not detected
           24  +# mmap mode.
           25  +#
           26  +# The reason is that in mmap mode, the different queries may use different
           27  +# PgHdr objects for the same page (same data, but different PgHdr container 
           28  +# objects). And so the corruption is not detected. 
           29  +#
           30  +if {[permutation]=="mmap"} {
           31  +  finish_test
           32  +  return
           33  +}
    22     34   
    23     35   # Initialize the database.
    24     36   #
    25     37   do_execsql_test 1.1 {
    26     38     PRAGMA page_size=1024;
    27     39   
    28     40     CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
................................................................................
    48     60     }
    49     61     db close
    50     62     hexio_write test.db [expr {($r(t2)-1)*1024 + 11}] [format %.2X $r(t1)]
    51     63     sqlite3 db test.db
    52     64   } {}
    53     65   
    54     66   do_test 1.3 {
           67  +breakpoint
    55     68     db eval { PRAGMA secure_delete=1 }
    56     69     list [catch {
    57     70       db eval { SELECT * FROM t1 WHERE a IN (1, 2) } {
    58     71         db eval { DELETE FROM t2 }
    59     72       }
    60     73     } msg] $msg
    61     74   } {1 {database disk image is malformed}}
................................................................................
    93    106     hexio_write test.db [expr {($fl-1) * 1024 + 8}] [format %.8X $r(t1)]
    94    107     hexio_write test.db 36 00000002
    95    108   
    96    109     sqlite3 db test.db
    97    110   } {}
    98    111   
    99    112   
   100         -# The corruption migration caused by the test case below does not 
   101         -# cause corruption to be detected in mmap mode.
   102         -#
   103    113   # The trick here is that the root page of the tree scanned by the outer 
   104    114   # query is also currently on the free-list. So while the first seek on
   105    115   # the table (for a==1) works, by the time the second is attempted The 
   106    116   # "INSERT INTO t2..." statements have recycled the root page of t1 and
   107    117   # used it as an index leaf. Normally, BtreeMovetoUnpacked() detects
   108    118   # that the PgHdr object associated with said root page does not match
   109    119   # the cursor (as it is now marked with PgHdr.intKey==0) and returns
   110    120   # SQLITE_CORRUPT. 
   111    121   #
   112         -# However, in mmap mode, the outer query and the inner queries use 
   113         -# different PgHdr objects (same data, but different PgHdr container 
   114         -# objects). And so the corruption is not detected. Instead, the second
   115         -# seek fails to find anything and only a single row is returned.
   116         -#
   117    122   set res23 {1 {database disk image is malformed}}
   118         -if {[permutation]=="mmap"} {
   119         -  set res23 {0 one}
   120         -}
   121    123   do_test 2.3 {
   122    124     list [catch {
   123    125     set res [list]
   124    126     db eval { SELECT * FROM t1 WHERE a IN (1, 2) } {
   125    127       db eval { 
   126    128         INSERT INTO t2 SELECT randomblob(100) FROM t2;
   127    129         INSERT INTO t2 SELECT randomblob(100) FROM t2;

Changes to test/uri.test.

   234    234   #
   235    235   ifcapable wal {
   236    236     testvfs tvfs1 
   237    237     tvfs1 filter {xOpen xDelete xAccess xFullPathname}
   238    238     tvfs1 script tvfs1_callback
   239    239     proc tvfs1_callback {method filename args} { 
   240    240       set ::T1([file tail $filename]) 1 
          241  +    return SQLITE_OK
   241    242     }
   242    243     testvfs tvfs2 
   243    244     tvfs2 filter {xOpen xDelete xAccess xFullPathname}
   244    245     tvfs2 script tvfs2_callback
   245    246     proc tvfs2_callback {method filename args} { 
   246    247       set ::T2([file tail $filename]) 1 
          248  +    return SQLITE_OK
   247    249     }
   248    250     
   249    251     catch {db close}
   250    252     eval forcedelete [glob test.db*]
   251    253     do_test 5.1.1 {
   252    254       sqlite3 db file:test.db1?vfs=tvfs1
   253    255       execsql {