/ Check-in [96f04d99]
Login

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

Overview
Comment:Check in the instrumented code for the mptest test case that appears to show a spontaneously disappearing journal file.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | missing-journal-file
Files: files | file ages | folders
SHA1: 96f04d99f3646189411cd6c6a3b5865f3e12d7d7
User & Date: dan 2013-04-09 19:19:01
Context
2013-04-09
19:19
Check in the instrumented code for the mptest test case that appears to show a spontaneously disappearing journal file. Closed-Leaf check-in: 96f04d99 user: dan tags: missing-journal-file
2013-04-08
20:47
Disable the use of memory-mapped I/O if the SQLITE_DISABLE_MMAP macro is defined. Automatically define this macro for OpenBSD and QNX. Other systems are likely to be added to the disabled list over time. check-in: 8a4314a3 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to mptest/config02.test.

     2      2   ** Configure five tasks in different ways, then run tests.
     3      3   */
     4      4   PRAGMA page_size=512;
     5      5   --task 1
     6      6     PRAGMA mmap_limit=0;
     7      7   --end
     8      8   --task 2
     9         -  PRAGMA mmap_limit=28672;
            9  +  PRAGMA mmap_limit=0;
    10     10   --end
    11     11   --task 3
    12         -  PRAGMA mmap_limit=8192;
           12  +  PRAGMA mmap_limit=0;
    13     13   --end
    14     14   --task 4
    15         -  PRAGMA mmap_limit=65536;
           15  +  PRAGMA mmap_limit=0;
    16     16   --end
    17     17   --source multiwrite01.test
    18     18   --source crash02.subtest
    19     19   PRAGMA page_size=1024;
    20     20   VACUUM;
    21     21   CREATE TABLE pgsz(taskid, sz INTEGER);
    22     22   --task 1

Changes to src/os_unix.c.

  1874   1874   ** Close a file.
  1875   1875   */
  1876   1876   static int unixClose(sqlite3_file *id){
  1877   1877     int rc = SQLITE_OK;
  1878   1878     unixFile *pFile = (unixFile *)id;
  1879   1879     unixUnlock(id, NO_LOCK);
  1880   1880     unixEnterMutex();
         1881  +
         1882  +access(pFile->zPath, F_OK);
  1881   1883   
  1882   1884     /* unixFile.pInode is always valid here. Otherwise, a different close
  1883   1885     ** routine (e.g. nolockClose()) would be called instead.
  1884   1886     */
  1885   1887     assert( pFile->pInode->nLock>0 || pFile->pInode->bProcessLock==0 );
  1886   1888     if( ALWAYS(pFile->pInode) && pFile->pInode->nLock ){
  1887   1889       /* If there are outstanding locks, do not actually close the file just
................................................................................
  3209   3211     ** file), the bytes in the locking range should never be read or written. */
  3210   3212   #if 0
  3211   3213     assert( pFile->pUnused==0
  3212   3214          || offset>=PENDING_BYTE+512
  3213   3215          || offset+amt<=PENDING_BYTE 
  3214   3216     );
  3215   3217   #endif
         3218  +
         3219  +access(pFile->zPath, F_OK);
  3216   3220   
  3217   3221   #ifdef SQLITE_DEBUG
  3218   3222     /* If we are doing a normal write to a database file (as opposed to
  3219   3223     ** doing a hot-journal rollback or a write to some file other than a
  3220   3224     ** normal database file) then record the fact that the database
  3221   3225     ** has changed.  If the transaction counter is modified, record that
  3222   3226     ** fact too.
................................................................................
  5570   5574       rc = findCreateFileMode(zName, flags, &openMode, &uid, &gid);
  5571   5575       if( rc!=SQLITE_OK ){
  5572   5576         assert( !p->pUnused );
  5573   5577         assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL );
  5574   5578         return rc;
  5575   5579       }
  5576   5580       fd = robust_open(zName, openFlags, openMode);
         5581  +    access(zName, F_OK);
  5577   5582       OSTRACE(("OPENX   %-3d %s 0%o\n", fd, zName, openFlags));
  5578   5583       if( fd<0 && errno!=EISDIR && isReadWrite && !isExclusive ){
  5579   5584         /* Failed to open the file for read/write access. Try read-only. */
  5580   5585         flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
  5581   5586         openFlags &= ~(O_RDWR|O_CREAT);
  5582   5587         flags |= SQLITE_OPEN_READONLY;
  5583   5588         openFlags |= O_RDONLY;
................................................................................
  5705   5710     sqlite3_vfs *NotUsed,     /* VFS containing this as the xDelete method */
  5706   5711     const char *zPath,        /* Name of file to be deleted */
  5707   5712     int dirSync               /* If true, fsync() directory after deleting file */
  5708   5713   ){
  5709   5714     int rc = SQLITE_OK;
  5710   5715     UNUSED_PARAMETER(NotUsed);
  5711   5716     SimulateIOError(return SQLITE_IOERR_DELETE);
         5717  +  access(zPath, F_OK);
  5712   5718     if( osUnlink(zPath)==(-1) ){
  5713   5719       if( errno==ENOENT ){
  5714   5720         rc = SQLITE_IOERR_DELETE_NOENT;
  5715   5721       }else{
  5716   5722         rc = unixLogError(SQLITE_IOERR_DELETE, "unlink", zPath);
  5717   5723       }
  5718   5724       return rc;

Changes to src/pager.c.

  1962   1962         assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE 
  1963   1963              || pPager->journalMode==PAGER_JOURNALMODE_MEMORY 
  1964   1964              || pPager->journalMode==PAGER_JOURNALMODE_WAL 
  1965   1965         );
  1966   1966         sqlite3OsClose(pPager->jfd);
  1967   1967         if( bDelete ){
  1968   1968           rc = sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);
         1969  +assert( rc!=SQLITE_IOERR_DELETE_NOENT );
  1969   1970         }
  1970   1971       }
  1971   1972     }
  1972   1973   
  1973   1974   #ifdef SQLITE_CHECK_PAGES
  1974   1975     sqlite3PcacheIterateDirty(pPager->pPCache, pager_set_pagehash);
  1975   1976     if( pPager->dbSize==0 && sqlite3PcacheRefCount(pPager->pPCache)>0 ){
................................................................................
  2469   2470         }
  2470   2471       }
  2471   2472       zJournal += (sqlite3Strlen30(zJournal)+1);
  2472   2473     }
  2473   2474    
  2474   2475     sqlite3OsClose(pMaster);
  2475   2476     rc = sqlite3OsDelete(pVfs, zMaster, 0);
         2477  +assert( rc!=SQLITE_IOERR_DELETE_NOENT );
  2476   2478   
  2477   2479   delmaster_out:
  2478   2480     sqlite3_free(zMasterJournal);
  2479   2481     if( pMaster ){
  2480   2482       sqlite3OsClose(pMaster);
  2481   2483       assert( !isOpen(pJournal) );
  2482   2484       sqlite3_free(pMaster);

Changes to src/vdbeaux.c.

  1927   1927       }
  1928   1928   
  1929   1929       /* Delete the master journal file. This commits the transaction. After
  1930   1930       ** doing this the directory is synced again before any individual
  1931   1931       ** transaction files are deleted.
  1932   1932       */
  1933   1933       rc = sqlite3OsDelete(pVfs, zMaster, 1);
         1934  +assert( rc!=SQLITE_IOERR_DELETE_NOENT );
  1934   1935       sqlite3DbFree(db, zMaster);
  1935   1936       zMaster = 0;
  1936   1937       if( rc ){
  1937   1938         return rc;
  1938   1939       }
  1939   1940   
  1940   1941       /* All files and directories have already been synced, so the following