Hi Derek,
On Thu, Jan 17 2013,
derek...@gmail.com wrote:
> The Xapian docs say that the locks on Xapian databases allow for one writer
> but multiple readers. Looking in mu-cmd.c, one can see how the mu
> implementation sets up a read-only store for "find" calls, but a read-write
> store for the other calls that hit the index:
>
> case MU_CONFIG_CMD_FIND:
> merr = with_store (mu_cmd_find, opts, TRUE, err); break;
> case MU_CONFIG_CMD_INDEX:
> merr = with_store (mu_cmd_index, opts, FALSE, err); break;
> case MU_CONFIG_CMD_ADD:
> merr = with_store (mu_cmd_add, opts, FALSE, err); break;
> case MU_CONFIG_CMD_REMOVE:
> merr = with_store (mu_cmd_remove, opts, FALSE, err); break;
> case MU_CONFIG_CMD_SERVER:
> merr = with_store (mu_cmd_server, opts, FALSE, err); break;
>
> This is why if you are running mu4e, no other mu process can refresh the
> index. The server is grabbing the write lock "just in case" it needs to
> write.
Indeed.
> Would it be possible to...
>
> 1. run mu_cmd_server in a read-only context, and
> 2. if mu_cmd_server needs to do a write action ("index", "add",
> "remove", possibly "guile"), have it allocate a writeable store alongside
> the read-only store and pass that to the callback, deallocating it at the
> end?
>
> This would let people run a background process to sync the maildir and
> refresh the index, and that process would continue to work properly whether
> they were running zero, one, or N instances of mu4e.
Possibly; however, the initial reason for keeping the database open all
the time is speed - open-closing the database could become rather
costly; removing 10 messages would require 10 open-close operations.
It'd be better if Xapian would support multiple writers... Or you can
you different databases.
Best wishes,
Dirk.
--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:
www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C