Hi, We are using xapian in .Net with the provided bindings. Currently we need to move the files forming an index into a database, so an index can be shared by several users of the application. It is a desktop application. So we have a Xapian.WritableDatabase which we do arbitrary updates on and at some time we call dispose on the index and then we want to copy the files. But this procedure keeps giving us errors because xapian does not release the locks it holds on the files, so we cannot get access to copy them. Is it not sufficient to call 'Dispose'. Should the object also be finalized before the locks on the files are release Best Regards Niels -- BinaryConstructors ApS Vestergade 10a, 4th 1456 Kbh K Denmark phone: +4528138757 web: http://www.binaryconstructors.dk mail: nb at binaryconstructors.dk skype: nielsboldt
Niels Boldt wrote:> Hi, > > We are using xapian in .Net with the provided bindings.Can you confirm you're using the C# bindings?> > Currently we need to move the files forming an index into a database, so an > index can be shared by several users of the application. It is a desktop > application.> So we have a Xapian.WritableDatabase which we do arbitrary updates on and at > some time we call dispose on the index and then we want to copy the files. > > But this procedure keeps giving us errors because xapian does not release > the locks it holds on the files, so we cannot get access to copy them. Is it > not sufficient to call 'Dispose'. Should the object also be finalized before > the locks on the files are releaseIf you can post source code that would be very helpful. Regards Charlie> > Best Regards > Niels > > >
2009/12/2 Niels Boldt <nielsboldt at gmail.com>:> But this procedure keeps giving us errors because xapian does not release > the locks it holds on the files, so we cannot get access to copy them. Is it > not sufficient to call 'Dispose'. Should the object also be finalized before > the locks on the files are releaseThis is a familiar problem, unfortunately. The problem is that Xapian's databases don't release the lock by default until the underlying C++ database object is deleted. In garbage collected languages, this is a particular problem, because the time at which the C++ object is freed is not obvious in advance. In addition, Xapian keeps references to the database from some of the other objects (eg, a Document opened from the database keeps a reference to the database), so the C++ database internals aren't freed until all such references have gone away (by the Document being deleted). The good news is that this is fixed in the 1.1.0 release series by adding a "close" method to the Database object. The bad news is that this is a development release series, and we're not quite ready to release the 1.2.0 stable release based on it (shouldn't be long now, though!) finalizing the object might help, but I'm not familiar enough with .Net to know whether that's something you can force, and whether it will force the underlying C++ object to be deleted. You'd need to make sure all objects derived from the Database object were finalised, too, as noted above, so any solution based on this won't be as reliable as using the close() method in the 1.1.x release series. -- Richard