Looks like I managed to remove the line that deletes (and thus closes
and unlocks) the Xapian::Database object in a bout of overzealous code
removal.  The consequence was exactly what you suspected; there was a
brief window after notmuch had exited before the database actually got
unlocked.  Here's the fix.  cworth, what's the most convenient way for
me to slip this in to the patch series?

diff --git a/lib/database.cc b/lib/database.cc
index 7253bdf..3c488a9 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -826,6 +826,7 @@ notmuch_database_close (notmuch_database_t *notmuch)
     }

     delete notmuch->term_gen;
+    delete notmuch->xapian_db;
     talloc_free (notmuch);
 }


On Fri, Jan 28, 2011 at 11:35 AM, Austin Clements <amdragon at mit.edu> wrote:
> This should most definitely not happen. ?I'll look in to it.
>
> On Fri, Jan 28, 2011 at 5:18 AM, Michal Sojka <sojkam1 at fel.cvut.cz> wrote:
>>
>> Hi Austin,
>>
>> when I switched to using your custom query parser I started experiencing
>> "Unable to get write lock" errors when I run my initial tagging script.
>> I thought that this was because I run the script while processing the
>> mail in Emacs, but today I realized that this happens even without Emacs
>> and that it can be reproduced by a simple command below.
>>
>> i=0; while notmuch tag +xxx tag:whatever; do i=$((i+1)); echo $i; done
>>
>> It seems that sometimes the unlocking of the Xapian database happens
>> somewhat lazily and when the subsequent command starts I get:
>>
>> A Xapian exception occurred opening database: Unable to get write lock on
>> /home/wsh/mail/.notmuch/xapian: already locked
>>
>> This happens almost regularly after a few iterations of the loop even if
>> the query doesn't match anything.
>>
>> Do you have an idea what may cause this?
>>
>> Can you reproduce this on your system?
>>
>> The version I use can be obtained from
>>
>> ?git://rtime.felk.cvut.cz/notmuch.git custom-query-pasrser
>>
>> Thanks
>> -Michal
>> _______________________________________________
>> notmuch mailing list
>> notmuch at notmuchmail.org
>> http://notmuchmail.org/mailman/listinfo/notmuch
>
>

Reply via email to