<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>On Thu, Oct 23, 2014, at 10:52 PM, 没有锂称 wrote:<br></div>
<blockquote type="cite"><div>Hello! I found a problem when write and read at the same time.<br></div>
<div>When I <span style="line-height: 1.5;">read the Database, </span><span style="line-height: 1.5;">there will appear 'DatabaseModifiedError' at sometimes</span><span style="line-height: 1.5;">. then I had to catch the '</span><span style="line-height: 1.5;"></span><span style="line-height: 1.5;">DatabaseModifiedError', reopen the Database and r</span><span style="line-height: 1.5;">epeat the last operation. But w</span><span style="line-height: 1.5;">hen the number of concurrent of the write is very high, the error </span><span style="line-height: 1.5;">'DatabaseModifiedError' will often appear. So, i</span>t seems not a good idea to <span style="line-height: 1.5;">catch and reopen the Database. Is there another method to </span>resolve the problem?<span style="display: none; line-height: 0px;"></span><br></div>
</blockquote><div> </div>
<div>We just use a separate external locking system, which is kind of sad - but it gets the job done :)<br></div>
<div> </div>
<div>Here's the full comment before we take the lock (which used to pass /*read*/0 as the last param)<br></div>
<div> </div>
<div> /* we grab an activefile writelock to index. Strictly we don't need it, but<br></div>
<div> * doing this guarantees we never write under a client which is reading, which<br></div>
<div> * avoids this:<br></div>
<div> *<br></div>
<div> * IOERROR: Xapian: caught exception: : DatabaseModifiedError: The revision<br></div>
<div> * being read has been discarded - you should call Xapian::Database::reopen()<br></div>
<div> * and retry the operation<br></div>
<div> *<br></div>
<div> * in theory, this will go away eventually, and we can switch back to write: 0<br></div>
<div> * in this code.<br></div>
<div> *<br></div>
<div> * <a href="http://grokbase.com/t/xapian/xapian-discuss/0667ppbks8/#20060608j8x5aeept49dv5fm8d02xkczgr">http://grokbase.com/t/xapian/xapian-discuss/0667ppbks8/#20060608j8x5aeept49dv5fm8d02xkczgr</a> <br></div>
<div> *<br></div>
<div> * "This is almost invariably caused by updating a database while reading<br></div>
<div> * from it. If two updates are committed before the read completes, you<br></div>
<div> * get this error (it's DatabaseModifiedError). It's a bit of a pain<br></div>
<div> * and will be going away in the future, but it's not too hard to design<br></div>
<div> * to avoid it happening at least."<br></div>
<div> */<br></div>
<div> active = activefile_open(mailbox->name, mailbox->part, &tr->activefile, /*write*/1);<br></div>
<div> </div>
<div>Cheers,<br></div>
<div> </div>
<div>Bron.<br></div>
<div> </div>
<div id="sig567075"><div class="signature">--<br></div>
<div class="signature">Bron Gondwana<br></div>
<div class="signature">brong@fastmail.fm<br></div>
<div class="signature"> </div>
</div>
<div> </div>
</body>
</html>