After some head scratching, I’ll retract my previous message. The documentation (as revised last week) is correct.
The previous version of wal.html mentioning “read mark” had led me down the wrong path in understanding which bit of the WAL was protected while a read lock was active. There is only one mark per read lock. The source code calls it aReadMark, but the documentation calls it “end mark”. Checkpoint can proceed up to the earliest end mark, because at that point the main database has the version of each page as seen by the reader with the earliest end mark (and that reader won’t need to reference the WAL any more). Other readers with later end marks can still use later parts of the WAL to access later versions of pages. Once the read lock with the earliest end mark is removed, checkpoint can proceed up to the next earliest end mark. If it catches up with the end of the WAL (no read locks, or no data written during the last read locks) then the WAL can reset to writing new data near the beginning. > On 27/05/2016, at 7:06 PM, David Empson <[email protected]> wrote: > >> On 26/05/2016, at 3:17 AM, Jeffrey Mattox <[email protected]> wrote: >> >> This page: >> https://www.sqlite.org/wal.html >> Contains the phrase, "... the checkpoint must stop when it reaches a page in >> the WAL that is past the read mark of any current reader." >> >> The term, "read mark" is not defined on that page. Should that be "end >> mark”? > > It appears the page has already been edited to that effect, but it doesn’t > make sense now. > > "A checkpoint can run concurrently with readers, however the checkpoint must > stop when it reaches a page in the WAL that is past the end mark of any > current reader. The checkpoint has to stop at that point because otherwise it > might overwrite part of the database file that the reader is actively using.” > > Readers are actively using pages BEFORE the end mark. > > The previous text was correct, but the term “read mark” needs to be > documented. > > Looking at the source code, there are two points involved in each read lock > for WAL mode: aReadMark[K] specifies the start of the read lock (which I > assume can increase as the read progresses, but I haven’t looked deeper to > confirm that), and mxFrame for the reader specifies the upper bound (which > will be the "end mark” in the documentation). > > Checkpointing can operate on frame numbers that are less than or equal to the > minimum used aReadMark[]. _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

