/ Check-in [726b425e]
Login

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

Overview
Comment:Still more refinements to the hasHotJournal() fix of ticket #3883. (CVS 6689)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 726b425e43e5d864e7e83853bdf134debc1ffb59
User & Date: drh 2009-05-29 11:57:38
Context
2009-05-29
14:39
Refinements in expression handling logic that have resulted from recent structural testing. (CVS 6690) check-in: bd89f2c2 user: drh tags: trunk
11:57
Still more refinements to the hasHotJournal() fix of ticket #3883. (CVS 6689) check-in: 726b425e user: drh tags: trunk
10:55
The hasHotJournal() fix of check-in (6687) causes some minor problems in various alternative operating modes, such as locking_mode=EXCLUSIVE. This additional patch attempts to fix those concerns. Ticket #3883. (CVS 6688) check-in: a2ba61d9 user: drh 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.589 2009/05/29 10:55:30 drh Exp $
           21  +** @(#) $Id: pager.c,v 1.590 2009/05/29 11:57:38 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   */
................................................................................
  3387   3387   
  3388   3388       /* Race condition here:  Another process might have been holding the
  3389   3389       ** the RESERVED lock and have a journal open at the sqlite3OsAccess() 
  3390   3390       ** call above, but then delete the journal and drop the lock before
  3391   3391       ** we get to the following sqlite3OsCheckReservedLock() call.  If that
  3392   3392       ** is the case, this routine might think there is a hot journal when
  3393   3393       ** in fact there is none.  This results in a false-positive which will
  3394         -    ** be dealt with by the playback routine under.  Ticket #3883.
         3394  +    ** be dealt with by the playback routine.  Ticket #3883.
  3395   3395       */
  3396   3396       rc = sqlite3OsCheckReservedLock(pPager->fd, &locked);
  3397   3397       if( rc==SQLITE_OK && !locked ){
  3398   3398         int nPage;
  3399   3399   
  3400   3400         /* Check the size of the database file. If it consists of 0 pages,
  3401   3401         ** then delete the journal file. See the header comment above for 
  3402   3402         ** the reasoning here.  Delete the obsolete journal file under
  3403         -      ** a RESERVED lock to avoid race conditions.
         3403  +      ** a RESERVED lock to avoid race conditions and to avoid violating
         3404  +      ** [H33020].
  3404   3405         */
  3405   3406         rc = sqlite3PagerPagecount(pPager, &nPage);
  3406   3407         if( rc==SQLITE_OK ){
  3407   3408           if( nPage==0 ){
  3408   3409             sqlite3BeginBenignMalloc();
  3409         -          if( pPager->exclusiveMode
         3410  +          if( pPager->state>=PAGER_RESERVED
  3410   3411                    ||  sqlite3OsLock(pPager->fd, RESERVED_LOCK)==SQLITE_OK ){
  3411   3412               sqlite3OsDelete(pVfs, pPager->zJournal, 0);
  3412         -            if( !pPager->exclusiveMode ){
         3413  +            assert( pPager->state>=PAGER_SHARED );
         3414  +            if( pPager->state==PAGER_SHARED ){
  3413   3415                 sqlite3OsUnlock(pPager->fd, SHARED_LOCK);
  3414   3416               }
  3415   3417             }
  3416   3418             sqlite3EndBenignMalloc();
  3417   3419           }else{
  3418   3420             /* The journal file exists and no other connection has a reserved
  3419   3421             ** or greater lock on the database file. Now check that there is