<div class="gmail_quote">2012/4/20 Olly Betts <span dir="ltr"><<a href="mailto:olly@survex.com">olly@survex.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Thu, Apr 19, 2012 at 03:45:36PM +0200, Websuche :: Felix Ostmann wrote:<br>
> I have a xapian-daemon, which can be queried via http. A background-process<br>
> generated every hour one new index and then remove and create a new symlink<br>
> to the current database.<br>
><br>
> /path/to/index/20120419010000<br>
> /path/to/index/20120419020000<br>
> /path/to/index/20120419030000<br>
> /path/to/index/default => /path/to/index/20120419030000<br>
<br>
</div>Note that using symlinks for this isn't recommended - Xapian opens the<br>
files using the given path, so if it is in the middle of opening the<br>
database when you switch the symlink, it'll try to open half the old<br>
one and half the new one, which isn't good at all.<br>
<br>
It's better to use a stub database file instead.<br></blockquote><div><br></div><div><div>The problem with the symlink is correct, but will only break 1 request when the system starts and that also only in theory. If such a open occure, the next request will close & open again (because the mtime of the iamchert is now newer).</div>
<div><br></div><div>I cannot follow your meaning of a stub-database, what do you mean?</div></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
> So the daemon only check the mtime of /path/to/index/default/iamchert befor<br>
> every request and if it is a new one, he close/reopen the database.<br>
><br>
> The problem is: There is no ->close in perl for a database! So currently i<br>
> override the object. After some days, the prozess have many open<br>
> filepointers to allready removed databases.<br>
<br>
</div>If you destroy all references to the database, it should get closed, so<br>
this suggests that either the Perl bindings aren't keeping track of the<br>
references correctly, or there's an object you have around still with a<br>
reference to the Database (keeping an Enquire or MSet or TermIterator or<br>
similar will implicitly keep a reference to the database).<br></blockquote><div><br></div><div><div>Perhaps i missed a reference, but i override the database, enquire and queryparser-object with there new one after a new open. No other objects should survive there scope.</div>
</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
> I also tried ->reopen, but xapian dont reopen every file, so after reopen,<br>
> i have some files opened from the old database and the record.DB from the<br>
> new one. Also the filepointer to the old record.DB still exists (i tested<br>
> with lsof -p $PID).<br>
<br>
</div>Calling reopen() will only update you to the latest revision of the<br>
database you originally opened - it doesn't work through symlinks like<br>
this (or through stub databases).<br>
<div class="im"><br>
> So what is the right way to make a clean shutdown of a opened xapian<br>
> database?<br>
<br>
</div>It should be enough to overwrite the perl variables which hold<br>
references, e.g.:<br>
<br>
$db = $enquire = $mset = undef;<br>
<br>
Though it is quite easy to miss an object. Or maybe there's a missing<br>
unreference somewhere.<br>
<br>
I thought we supported Database::close() in Perl, but it looks like when<br>
the wrapper was contributed, it was put on WritableDatabase only, which<br>
was wrong. You can probably just copy the close bit from<br>
XS/WritableDatabase.xs to XS/Database.xs if you want to fix it locally.<br>
If you do, a patch would be great. Otherwise I'll attend to it when I<br>
have a bit more spare time.<br></blockquote><div><br></div><div>OK, i simple copied the close() from XS/WriteableDatabase.xs to XS/Database.xs and all works as expected.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
Olly<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><span>Mit freundlichem Gruß</span><br><span>Felix Ostmann</span><br><br><font><span style="font-family:'courier new',monospace">-----------------------------------------------------------</span><br style="font-family:'courier new',monospace">
<span style="font-family:'courier new',monospace">Websuche Search Technology GmbH & Co. KG</span><br style="font-family:'courier new',monospace"><span style="font-family:'courier new',monospace">Martinistraße 3, D-49080 Osnabrück, Germany</span><br style="font-family:'courier new',monospace">
<span style="font-family:'courier new',monospace">-----------------------------------------------------------</span><br style="font-family:'courier new',monospace"><span style="font-family:'courier new',monospace">Tel.: +49 (0) 541 / 40666 0, Fax: +49 (0) 541 / 40666 22</span><br style="font-family:'courier new',monospace">
<span style="font-family:'courier new',monospace">Email: <a href="mailto:info@websuche.com" style="color:rgb(17,85,204)" target="_blank">info@websuche.com</a>, Web: <a href="http://www.websuche.com/" style="color:rgb(17,85,204)" target="_blank">www.websuche.com</a></span><br style="font-family:'courier new',monospace">
<span style="font-family:'courier new',monospace">-----------------------------------------------------------</span><br style="font-family:'courier new',monospace"><span style="font-family:'courier new',monospace">AG Osnabrück - HRA 200252, Ust-IdNr.: DE814737310</span><br style="font-family:'courier new',monospace">
<span style="font-family:'courier new',monospace">-----------------------------------------------------------</span><br style="font-family:'courier new',monospace"><span style="font-family:'courier new',monospace">Komplementärin: Websuche Search Technology Verwaltungs GmbH</span><br style="font-family:'courier new',monospace">
<span style="font-family:'courier new',monospace">AG Osnabrück - HRB 200359, Geschäftsführer: Ansas Meyer</span><br style="font-family:'courier new',monospace"><span style="font-family:'courier new',monospace">-----------------------------------------------------------</span><br style="font-family:'courier new',monospace">
<br style="font-family:'courier new',monospace"><span style="font-family:'courier new',monospace">Die in dieser Email enthaltenen Informationen sind vertrau-</span><br style="font-family:'courier new',monospace">
<span style="font-family:'courier new',monospace">lich zu behandeln und ausschließlich für den Adressaten be-</span><br style="font-family:'courier new',monospace"><span style="font-family:'courier new',monospace">stimmt. Jegliche Veröffentlichung, Verteilung oder sonstige</span><br style="font-family:'courier new',monospace">
<span style="font-family:'courier new',monospace">in diesem Zusammenhang stehende Handlung wird ausdrücklich</span><br style="font-family:'courier new',monospace"><span style="font-family:'courier new',monospace">untersagt.</span></font><br>