Websuche :: Felix Ostmann
2012-Apr-19 13:45 UTC
[Xapian-devel] Xapian::Database->close() for perl missing
I have a xapian-daemon, which can be queried via http. A background-process generated every hour one new index and then remove and create a new symlink to the current database. /path/to/index/20120419010000 /path/to/index/20120419020000 /path/to/index/20120419030000 /path/to/index/default => /path/to/index/20120419030000 So the daemon only check the mtime of /path/to/index/default/iamchert befor every request and if it is a new one, he close/reopen the database. The problem is: There is no ->close in perl for a database! So currently i override the object. After some days, the prozess have many open filepointers to allready removed databases. I also tried ->reopen, but xapian dont reopen every file, so after reopen, i have some files opened from the old database and the record.DB from the new one. Also the filepointer to the old record.DB still exists (i tested with lsof -p $PID). So what is the right way to make a clean shutdown of a opened xapian database? I tested with xapian-core 1.2.9 / Search::Xapian 1.2.9.0 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xapian.org/pipermail/xapian-devel/attachments/20120419/dd5c30cb/attachment.html>
Olly Betts
2012-Apr-19 22:46 UTC
[Xapian-devel] Xapian::Database->close() for perl missing
On Thu, Apr 19, 2012 at 03:45:36PM +0200, Websuche :: Felix Ostmann wrote:> I have a xapian-daemon, which can be queried via http. A background-process > generated every hour one new index and then remove and create a new symlink > to the current database. > > /path/to/index/20120419010000 > /path/to/index/20120419020000 > /path/to/index/20120419030000 > /path/to/index/default => /path/to/index/20120419030000Note that using symlinks for this isn't recommended - Xapian opens the files using the given path, so if it is in the middle of opening the database when you switch the symlink, it'll try to open half the old one and half the new one, which isn't good at all. It's better to use a stub database file instead.> So the daemon only check the mtime of /path/to/index/default/iamchert befor > every request and if it is a new one, he close/reopen the database. > > The problem is: There is no ->close in perl for a database! So currently i > override the object. After some days, the prozess have many open > filepointers to allready removed databases.If you destroy all references to the database, it should get closed, so this suggests that either the Perl bindings aren't keeping track of the references correctly, or there's an object you have around still with a reference to the Database (keeping an Enquire or MSet or TermIterator or similar will implicitly keep a reference to the database).> I also tried ->reopen, but xapian dont reopen every file, so after reopen, > i have some files opened from the old database and the record.DB from the > new one. Also the filepointer to the old record.DB still exists (i tested > with lsof -p $PID).Calling reopen() will only update you to the latest revision of the database you originally opened - it doesn't work through symlinks like this (or through stub databases).> So what is the right way to make a clean shutdown of a opened xapian > database?It should be enough to overwrite the perl variables which hold references, e.g.: $db = $enquire = $mset = undef; Though it is quite easy to miss an object. Or maybe there's a missing unreference somewhere. I thought we supported Database::close() in Perl, but it looks like when the wrapper was contributed, it was put on WritableDatabase only, which was wrong. You can probably just copy the close bit from XS/WritableDatabase.xs to XS/Database.xs if you want to fix it locally. If you do, a patch would be great. Otherwise I'll attend to it when I have a bit more spare time. Cheers, Olly
Reasonably Related Threads
- Streaming ogg from filepointer pointing to archive of many oggs. Ogg stream does not stop after end of one ogg file - what to do ?
- Is this a bug in ogg ?
- A beginner in "Posting list encoding improvements"
- 回复: A beginner in "Posting list encoding improvements"
- Samba and ClearCase