Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Make the winTruncate() method of the windows VFS be a no-op if there are outstanding references to the memory-mapped pages. Otherwise, memory might be deleted out from under those references when the file is remapped during the truncate operation. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | branch-3.25 |
Files: | files | file ages | folders |
SHA3-256: |
8576ccb479fc4b76e950a5c2c5db5c57 |
User & Date: | drh 2018-11-23 13:21:05 |
Context
2018-11-24
| ||
17:46 | Make the winTruncate() method of the windows VFS be a no-op if there are outstanding references to the memory-mapped pages. Otherwise, memory might be deleted out from under those references when the file is remapped during the truncate operation. (check-in: ffce4aac user: drh tags: trunk) | |
2018-11-23
| ||
13:21 | Make the winTruncate() method of the windows VFS be a no-op if there are outstanding references to the memory-mapped pages. Otherwise, memory might be deleted out from under those references when the file is remapped during the truncate operation. (Leaf check-in: 8576ccb4 user: drh tags: branch-3.25) | |
2018-11-05
| ||
20:37 | Version 3.25.3 (check-in: 89e099fb user: drh tags: release, version-3.25.3, branch-3.25) | |
Changes
Changes to src/os_win.c.
︙ | ︙ | |||
2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 | */ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){ winFile *pFile = (winFile*)id; /* File handle object */ int rc = SQLITE_OK; /* Return code for this function */ DWORD lastErrno; #if SQLITE_MAX_MMAP_SIZE>0 sqlite3_int64 oldMmapSize; #endif assert( pFile ); SimulateIOError(return SQLITE_IOERR_TRUNCATE); OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n", osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype)); | > | 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 | */ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){ winFile *pFile = (winFile*)id; /* File handle object */ int rc = SQLITE_OK; /* Return code for this function */ DWORD lastErrno; #if SQLITE_MAX_MMAP_SIZE>0 sqlite3_int64 oldMmapSize; if( pFile->nFetchOut>0 ) return SQLITE_OK; #endif assert( pFile ); SimulateIOError(return SQLITE_IOERR_TRUNCATE); OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n", osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype)); |
︙ | ︙ |
Changes to test/incrvacuum.test.
︙ | ︙ | |||
778 779 780 781 782 783 784 785 786 | catchsql {INSERT INTO t2 SELECT * FROM t1} execsql { COMMIT; PRAGMA integrity_check; } } {ok} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 | catchsql {INSERT INTO t2 SELECT * FROM t1} execsql { COMMIT; PRAGMA integrity_check; } } {ok} #------------------------------------------------------------------------- # At one point it was unsafe to truncate a db file on windows while there # were outstanding xFetch() references. This test case attempts to hit # that case. # reset_db do_execsql_test incrvacuum-16.0 { PRAGMA auto_vacuum = 2; CREATE TABLE t3(a); INSERT INTO t3 VALUES(1), (2), (3), (4); CREATE TABLE t2(x); INSERT INTO t2 VALUES( randomblob(1000) ); INSERT INTO t2 VALUES( randomblob(1000) ); INSERT INTO t2 VALUES( randomblob(1000) ); INSERT INTO t2 VALUES( randomblob(1000) ); INSERT INTO t2 VALUES( randomblob(1000) ); INSERT INTO t2 VALUES( randomblob(1000) ); } {} # Reopen db to ensure the page-cache is empty. # db close sqlite3 db test.db # Open db in mmap-mode. Open a transaction, delete some data, then run # incremental-vacuum. Do not commit the transaction. # do_execsql_test incrvacuum-16.1 { PRAGMA mmap_size = 1000000; BEGIN; DELETE FROM t2; PRAGMA incremental_vacuum = 1000; } {1000000} # Scan through table t3 (which is all clean pages - so mmap is used). Then, # midway through, commit the transaction. This causes the db to be truncated # while there are outstanding xFetch pages. # do_test incrvacuum-16.2 { set res [list] db eval { SELECT a FROM t3 } { if {$a==3} { db eval COMMIT } lappend res $a } set res } {1 2 3 4} finish_test |