[PATCH 1/4] Use the Xapian::DB_RETRY_LOCK flag when available This is the original patch, rebased on master. I took the liberty of converting the configure test to a test compile. [PATCH 2/4] test: factor out some boilerplate from C tests [PATCH 3/4] test: initial tests for locking retry Add a simple test of locking retry. [PATCH 4/4] lib: add built_with handling for XAPIAN_DB_RETRY_LOCK Make it visible to the user whether their notmuch supports locking retry (blocking open). The remaining question for me is if we are happy with defaulting to blocking (w/o timeout) on open. I'm not sure how you could deadlock without writing C code, but it's pretty easy with fork. As I discovered writing my test case.