Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Get read-only SHM file tests passing on Win32. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | readonly-wal-recovery |
Files: | files | file ages | folders |
SHA3-256: |
abef05353554e72f4d08aff562b87ff8 |
User & Date: | mistachkin 2017-11-09 20:02:44 |
Context
2017-11-09
| ||
20:34 | Enhance walro2.test to better ensure that readonly_shm clients are not using invalid *-shm files. check-in: ff630b66 user: dan tags: readonly-wal-recovery | |
20:02 | Get read-only SHM file tests passing on Win32. check-in: abef0535 user: mistachkin tags: readonly-wal-recovery | |
18:53 | Further corrections to read-only SHM file handling on Win32. check-in: 43c31170 user: mistachkin tags: readonly-wal-recovery | |
Changes
Changes to src/os_win.c.
2095 2095 #ifndef SQLITE_WIN32_IOERR_RETRY_DELAY 2096 2096 # define SQLITE_WIN32_IOERR_RETRY_DELAY 25 2097 2097 #endif 2098 2098 static int winIoerrRetry = SQLITE_WIN32_IOERR_RETRY; 2099 2099 static int winIoerrRetryDelay = SQLITE_WIN32_IOERR_RETRY_DELAY; 2100 2100 2101 2101 /* 2102 -** The "winIsLockingError" macro is used to determine if a particular I/O 2103 -** error code is due to file locking. It must accept the error code DWORD 2104 -** as its only argument and should return non-zero if the error code is due 2105 -** to file locking. 2102 +** The "winIsLockConflict" macro is used to determine if a particular I/O 2103 +** error code is due to a file locking conflict. It must accept the error 2104 +** code DWORD as its only argument. 2106 2105 */ 2107 -#if !defined(winIsLockingError) 2108 -#define winIsLockingError(a) (((a)==NO_ERROR) || \ 2106 +#if !defined(winIsLockConflict) 2107 +#define winIsLockConflict(a) (((a)==NO_ERROR) || \ 2109 2108 ((a)==ERROR_LOCK_VIOLATION) || \ 2110 - ((a)==ERROR_HANDLE_EOF) || \ 2111 2109 ((a)==ERROR_IO_PENDING)) 2112 2110 #endif 2113 2111 2112 +/* 2113 +** The "winIsLockMissing" macro is used to determine if a particular I/O 2114 +** error code is due to being unable to obtain a file lock because all or 2115 +** part of the range requested within the file is missing. It must accept 2116 +** the error code DWORD as its only argument. 2117 +*/ 2118 +#if !defined(winIsLockMissing) 2119 +#define winIsLockMissing(a) (((a)==ERROR_HANDLE_EOF)) 2120 +#endif 2121 + 2114 2122 /* 2115 2123 ** The "winIoerrCanRetry1" macro is used to determine if a particular I/O 2116 2124 ** error code obtained via GetLastError() is eligible to be retried. It 2117 2125 ** must accept the error code DWORD as its only argument and should return 2118 2126 ** non-zero if the error code is transient in nature and the operation 2119 2127 ** responsible for generating the original error might succeed upon being 2120 2128 ** retried. The argument to this macro should be a variable. ................................................................................ 3870 3878 pOverlapped = &overlapped; 3871 3879 #endif 3872 3880 if( bReadOnly || 3873 3881 !osWriteFile(pFile->h, ¬Used1, 1, ¬Used2, pOverlapped) ){ 3874 3882 DWORD lastErrno = bReadOnly ? NO_ERROR : osGetLastError(); 3875 3883 if( !osReadFile(pFile->h, ¬Used1, 1, ¬Used2, pOverlapped) ){ 3876 3884 lastErrno = osGetLastError(); 3877 - if( winIsLockingError(lastErrno) ){ 3885 + if( winIsLockConflict(lastErrno) ){ 3878 3886 if( pLockType ) *pLockType = WINSHM_WRLCK; 3887 + }else if( winIsLockMissing(lastErrno) ){ 3888 + if( pLockType ) *pLockType = WINSHM_UNLCK; 3879 3889 }else{ 3880 3890 return SQLITE_IOERR_READ; 3881 3891 } 3882 3892 }else{ 3883 - if( winIsLockingError(lastErrno) ){ 3893 + if( winIsLockConflict(lastErrno) ){ 3884 3894 if( pLockType ) *pLockType = WINSHM_RDLCK; 3885 3895 }else{ 3886 3896 return SQLITE_IOERR_WRITE; 3887 3897 } 3888 3898 } 3889 3899 }else{ 3890 3900 if( pLockType ) *pLockType = WINSHM_UNLCK; ................................................................................ 4020 4030 if( rc2!=SQLITE_OK ){ 4021 4031 rc2 = winOpen(pDbFd->pVfs, 4022 4032 pShmNode->zFilename, 4023 4033 (sqlite3_file*)&pShmNode->hFile, 4024 4034 SQLITE_OPEN_WAL|SQLITE_OPEN_READONLY, 4025 4035 0); 4026 4036 if( rc2!=SQLITE_OK ){ 4027 - rc = winLogError(SQLITE_CANTOPEN_BKPT, osGetLastError(), 4028 - "winOpenShm", pShmNode->zFilename); 4037 + rc = winLogError(rc2, osGetLastError(), "winOpenShm", 4038 + pShmNode->zFilename); 4029 4039 goto shm_open_err; 4030 4040 } 4031 4041 pShmNode->isReadonly = 1; 4032 4042 } 4033 4043 4034 4044 rc = winLockSharedMemory(pShmNode); 4035 4045 if( rc!=SQLITE_OK && rc!=SQLITE_READONLY_CANTINIT ) goto shm_open_err;
Changes to test/walro2.test.
251 251 SELECT count(*) FROM t2; 252 252 } 253 253 } {500} 254 254 do_test 4.2.2 { 255 255 file size test.db-wal 256 256 } {461152} 257 257 do_test 4.2.4 { 258 + file_control_persist_wal db 1; db close 259 + 258 260 forcecopy test.db test.db2 259 261 forcecopy test.db-wal test.db2-wal 260 262 forcecopy test.db-shm test.db2-shm 261 263 262 264 code2 { sqlite3 db2 file:test.db2?readonly_shm=1 } 263 265 sql2 { 264 266 SELECT * FROM t1;
Changes to test/walrofault.test.
38 38 INSERT INTO t1 VALUES('world'); 39 39 INSERT INTO t1 VALUES('hello'); 40 40 PRAGMA cache_size = 10; 41 41 BEGIN; 42 42 WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<30 ) 43 43 INSERT INTO t1(b) SELECT randomblob(800) FROM s; 44 44 } {wal} 45 +file_control_persist_wal db 1; db close 45 46 faultsim_save_and_close 46 47 47 48 do_faultsim_test 1 -faults oom* -prep { 48 49 catch { db close } 49 50 faultsim_restore 50 51 sqlite3 db file:test.db?readonly_shm=1 51 52 } -body {