]> git.cworth.org Git - notmuch/commitdiff
dump: make dump take Xapian write lock
authorMark Walters <markwalters1009@gmail.com>
Mon, 23 Jun 2014 20:12:29 +0000 (21:12 +0100)
committerDavid Bremner <david@tethera.net>
Wed, 16 Jul 2014 22:33:10 +0000 (19:33 -0300)
Dump currently only takes the read lock. Xapian can cope with some
changes while maintaining a read snapshot but with more changes it
fails. Currently notmuch just gives a xapian error.

To avoid this we take the write lock when dumping. This prevents other
notmuch processes from modifying the xapian database preventing this
error.

Discussion with Olly on irc indicates that this is currently the best
solution: in xapian trunk there may be better possibilities using
snapshots but they need to make it to a release and propogate out to
users before we can switch approach.

Finally, this breaks one use case: pipelines of the form

notmuch dump | ... | notmuch restore

According to Olly this is already very fragile: it will only work on
small databases. One of the tests relies on this behaviour so fix that
to store the dump rather than use a pipe.

notmuch-dump.c
test/T150-tagging.sh

index 887a20822d828ef6dab98f58f156e37bebefdf06..9c6ad7f47b0fde514a5e64c96705d598f2eee7ec 100644 (file)
@@ -212,7 +212,7 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])
     int ret;
 
     if (notmuch_database_open (notmuch_config_get_database_path (config),
-                              NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch))
+                              NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch))
        return EXIT_FAILURE;
 
     char *output_file_name = NULL;
index dc118f331ff054ac53476a7221e1d9f42a35d987..45471ac8de72962937761873c81b1f6bcb229609 100755 (executable)
@@ -247,8 +247,8 @@ ${TEST_DIRECTORY}/random-corpus --config-path=${NOTMUCH_CONFIG} \
 notmuch dump --format=batch-tag | sed 's/^.* -- /+common_tag -- /' | \
     sort > EXPECTED
 
-notmuch dump --format=batch-tag | sed 's/^.* -- /  -- /' | \
-    notmuch restore --format=batch-tag
+notmuch dump --format=batch-tag | sed 's/^.* -- /  -- /' > INTERMEDIATE_STEP
+notmuch restore --format=batch-tag < INTERMEDIATE_STEP
 
 notmuch tag --batch < EXPECTED