Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch more-aggressive-wal-recovery Excluding Merge-Ins
This is equivalent to a diff from 73fecc688a to 3549faefea
2020-07-28
| ||
17:29 | If a writer crashes in WAL mode and leave the SHM file in an inconsistent state, subsequent transactions are now able to recover the SHM file even if there are active read transactions. (check-in: ee8a108058 user: drh tags: trunk) | |
2020-07-25
| ||
20:16 | When trying to read the index header, accept either of the two headers that have a valid checksum after 15 attempts to get exactly matching headers fail. (Closed-Leaf check-in: 3549faefea user: drh tags: more-aggressive-wal-recovery) | |
20:16 | Allow a wal mode recovery to proceed even if there are readers. (check-in: 74374aebf9 user: dan tags: unlocked-recovery) | |
2020-07-24
| ||
13:49 | Merge recent changes from trunk. (check-in: 22e8e6901a user: drh tags: larger-databases) | |
11:01 | Remove a surplus space from a comment (check-in: 73fecc688a user: drh tags: trunk) | |
09:17 | Fix other potentiall pointer aliasing problems associated with subclassing of the sqlite3_file object for various VFS implementations. (check-in: 270ac1a0f2 user: drh tags: trunk) | |
Changes to src/wal.c.
︙ | |||
2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 | 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 | + + + + + + + + + + + + + - + | } WALTRACE(("WAL%p: closed\n", pWal)); sqlite3_free((void *)pWal->apWiData); sqlite3_free(pWal); } return rc; } /* ** Return true if the wal-index header seems valid based on the ** checksum. */ static int walIndexHdrValid(WalIndexHdr *p){ u32 aCksum[2]; if( p->isInit==0 ) return 0; walChecksumBytes(1, (u8*)p, sizeof(*p)-sizeof(p->aCksum), 0, aCksum); if( aCksum[0]!=p->aCksum[0] ) return 0; if( aCksum[1]!=p->aCksum[1] ) return 0; return 1; } /* ** Try to read the wal-index header. Return 0 on success and 1 if ** there is a problem. ** ** The wal-index is in shared memory. Another thread or process might ** be writing the header at the same time this procedure is trying to ** read it, which might result in inconsistency. A dirty read is detected ** by verifying that both copies of the header are the same and also by ** a checksum on the header. ** ** If and only if the read is consistent and the header is different from ** pWal->hdr, then pWal->hdr is updated to the content of the new header ** and *pChanged is set to 1. ** ** If the checksum cannot be verified return non-zero. If the header ** is read successfully and the checksum verified, return zero. */ |
︙ | |||
2175 2176 2177 2178 2179 2180 2181 | 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 | - + - - + + + + - - - - - + - | ** give false-positive warnings about these accesses because the tools do not ** account for the double-read and the memory barrier. The use of mutexes ** here would be problematic as the memory being accessed is potentially ** shared among multiple processes and not all mutex implementions work ** reliably in that environment. */ aHdr = walIndexHdr(pWal); |
︙ | |||
2220 2221 2222 2223 2224 2225 2226 | 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 | - + | ** Set *pChanged to 1 if the wal-index header value in pWal->hdr is ** changed by this operation. If pWal->hdr is unchanged, set *pChanged ** to 0. ** ** If the wal-index header is successfully read, return SQLITE_OK. ** Otherwise an SQLite error code. */ |
︙ | |||
2260 2261 2262 2263 2264 2265 2266 | 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 | - + - + | assert( page0!=0 || pWal->writeLock==0 ); /* If the first page of the wal-index has been mapped, try to read the ** wal-index header immediately, without holding any lock. This usually ** works, but may fail if the wal-index header is corrupt or currently ** being modified by another thread or process. */ |
︙ | |||
2582 2583 2584 2585 2586 2587 2588 | 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 | - + | if( cnt>=10 ) nDelay = (cnt-9)*(cnt-9)*39; sqlite3OsSleep(pWal->pVfs, nDelay); } if( !useWal ){ assert( rc==SQLITE_OK ); if( pWal->bShmUnreliable==0 ){ |
︙ | |||
3741 3742 3743 3744 3745 3746 3747 | 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 | - + | } } /* Read the wal-index header. */ if( rc==SQLITE_OK ){ walDisableBlocking(pWal); |
︙ |