You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by Terry Rosenbaum <Te...@amicas.com> on 2002/09/16 23:08:01 UTC
Collection Files Left Undeleted After Drop of Collection
Hi,
I'm using Xindice embedded on Windows.
I've noticed that there are unclosed file
handles to a Collections files that are preventing
deletion of the files when dropping the Collection
if the Collection has already been opened in the process.
This happens even if the Collection has been close()ed before
attempting to drop it.
Here is the sequence of events (error checking removed for brevity):
Collection aRootCollection = null;
Collection aTestCollection = null;
try
{
aRootCollection =
DatabaseManager.getCollection("xmldb:xindice-embed:///db/");
CollectionManager aService =
(CollectionManager)aRootCollection.getService(
"CollectionManager", "1.0");
// drop the existing child collection ("Test" Collection)
if present
aService.dropCollection("Test");
String aConfig = "<collection compressed=\"true\"
name=\"Test\">" +
"<filer
class=\"org.apache.xindice.core.filer.BTreeFiler\" gzip=\"false\"/>" +
"</collection>";
// get the collection configuration
Document aConfigDocument =
org.apache.xindice.xml.dom.DOMParser.toDocument(aConfig);
// create the new collection
aTestCollection = aService.createCollection("Test",
aConfigDocument);
// get the Test Collection's CollectionManager
aService = (CollectionManager)aTestCollection .getService(
"CollectionManager", "1.0");
}
finally
{
if(aRootCollection != null)
{
try
{
aRootCollection.close();
}
catch(XMLDBException anException)
{
}
}
if(aTestCollection != null)
{
try
{
aTestCollection .close();
}
catch(XMLDBException anException)
{
}
}
If I execute the above sequence of events twice within
my process, the Test.tbl file is not deleted when
aService.dropCollection("Test");
is called the second time.
This is due to open file handles in the Filer for the Collection.
On Windows, the open handles prevent deletion of the file.
File.delete() returns false, but this return is not checked in
Xindice code.
Is there some way to fully "close" a Collection such that the Collection
can really be dropped without exiting the process?
I believe that this issue only becomes apparent on Windows
due to its different handling of file deletion of open files compared to
how various unix systems handle this. On unix, the file will actually
disappear from view in the file system when File.delete() is called,
even if there are open handles. On windows, the file remains in view
in the file system and File.delete() returns false.
Each time a collection is created, two new RandomAccessFiles for the
collection's
".tbl" file are created/opened that never get destroyed until the
process exits (unless, perhaps they are left
to twist in the wind and get gc'ed). Even if you drop the Collection
after creating
it, these files are never destroyed. These are the open file handles
preventing the
Collection files from being deleted. Here is the stack trace from each
of those creation
events:
1)
at org.apache.xindice.core.filer.Paged.getDescriptor(Paged.java:127)
at org.apache.xindice.core.filer.Paged.open(Paged.java:405)
at org.apache.xindice.core.filer.BTree.open(BTree.java:119)
at org.apache.xindice.core.filer.BTreeFiler.open(BTreeFiler.java:105)
at org.apache.xindice.core.Collection.setConfig(Collection.java:187)
at
org.apache.xindice.core.CollectionManager.createCollection(CollectionManager.java:232)
at
org.apache.xindice.core.Collection.createCollection(Collection.java:241)
at
org.apache.xindice.client.xmldb.embed.CollectionImpl.createCollection(CollectionImpl.java:449)
at
org.apache.xindice.client.xmldb.services.CollectionManagementServiceImpl.createCollection(CollectionManagementServiceImpl.java:202)
2)
at org.apache.xindice.core.filer.Paged.getDescriptor(Paged.java:127)
at org.apache.xindice.core.filer.Paged$FileHeader.read(Paged.java:662)
at org.apache.xindice.core.filer.Paged.open(Paged.java:406)
at org.apache.xindice.core.filer.BTree.open(BTree.java:119)
at org.apache.xindice.core.filer.BTreeFiler.open(BTreeFiler.java:105)
at org.apache.xindice.core.Collection.setConfig(Collection.java:187)
at
org.apache.xindice.core.CollectionManager.createCollection(CollectionManager.java:232)
at
org.apache.xindice.core.Collection.createCollection(Collection.java:241)
at
org.apache.xindice.client.xmldb.embed.CollectionImpl.createCollection(CollectionImpl.java:449)
at
org.apache.xindice.client.xmldb.services.CollectionManagementServiceImpl.createCollection(CollectionManagementServiceImpl.java:202)
If anyone can provide any insights, I'd be most appreciative.
Thanks.
-Terry