notmuch/lib
Austin Clements 7f57b747b9 lib: Add per-message last modification tracking
This adds a new document value that stores the revision of the last
modification to message metadata, where the revision number increases
monotonically with each database commit.

An alternative would be to store the wall-clock time of the last
modification of each message.  In principle this is simpler and has
the advantage that any process can determine the current timestamp
without support from libnotmuch.  However, even assuming a computer's
clock never goes backward and ignoring clock skew in networked
environments, this has a fatal flaw.  Xapian uses (optimistic)
snapshot isolation, which means reads can be concurrent with writes.
Given this, consider the following time line with a write and two read
transactions:

   write  |-X-A--------------|
   read 1       |---B---|
   read 2                      |---|

The write transaction modifies message X and records the wall-clock
time of the modification at A.  The writer hangs around for a while
and later commits its change.  Read 1 is concurrent with the write, so
it doesn't see the change to X.  It does some query and records the
wall-clock time of its results at B.  Transaction read 2 later starts
after the write commits and queries for changes since wall-clock time
B (say the reads are performing an incremental backup).  Even though
read 1 could not see the change to X, read 2 is told (correctly) that
X has not changed since B, the time of the last read.  In fact, X
changed before wall-clock time A, but the change was not visible until
*after* wall-clock time B, so read 2 misses the change to X.

This is tricky to solve in full-blown snapshot isolation, but because
Xapian serializes writes, we can use a simple, monotonically
increasing database revision number.  Furthermore, maintaining this
revision number requires no more IO than a wall-clock time solution
because Xapian already maintains statistics on the upper (and lower)
bound of each value stream.
2015-08-13 23:52:51 +02:00
..
database-private.h lib: Add per-message last modification tracking 2015-08-13 23:52:51 +02:00
database.cc lib: Add per-message last modification tracking 2015-08-13 23:52:51 +02:00
directory.cc lib: replace almost all fprintfs in library with _n_d_log 2015-03-29 00:34:15 +01:00
filenames.c lib: fix NULL checks for filenames iterators 2012-09-01 23:03:11 -03:00
gen-version-script.sh build: add "set -eu" to version script generation 2015-07-28 21:34:01 +02:00
index.cc lib: replace almost all fprintfs in library with _n_d_log 2015-03-29 00:34:15 +01:00
libsha1.c util: detect byte order 2013-11-27 07:43:29 -04:00
libsha1.h fix sum moar typos [comments in source code] 2011-06-23 15:58:39 -07:00
Makefile fix sum moar typos [build scripts, Makefiles] 2011-06-23 15:44:59 -07:00
Makefile.local build: extract library versions from notmuch.h 2015-08-10 13:53:55 +02:00
message-file.c lib: eliminate fprintf from _notmuch_message_file_open 2015-03-29 00:34:15 +01:00
message.cc lib: Add per-message last modification tracking 2015-08-13 23:52:51 +02:00
messages.c lib: Eliminate _notmuch_message_list_append 2013-02-18 20:20:38 -04:00
notmuch-private.h lib: Add per-message last modification tracking 2015-08-13 23:52:51 +02:00
notmuch.h build: extract library versions from notmuch.h 2015-08-10 13:53:55 +02:00
parse-time-vrp.cc lib: add date range query support 2012-10-31 16:55:32 -03:00
parse-time-vrp.h lib: add date range query support 2012-10-31 16:55:32 -03:00
query.cc lib: add public accessor for database from query 2015-08-04 09:11:34 +02:00
sha1.c lib: Start all function names in notmuch-private.h with 2014-07-13 12:25:29 -03:00
string-list.c Fixup string list author 2011-03-21 02:45:18 -04:00
tags.c lib: fix warnings when building with clang 2012-12-01 08:10:32 -04:00
thread.cc lib: Fix use after free 2015-01-19 08:15:14 +01:00