This is an update, and further problem, on a problem I posted here a few months 
ago. I've written a program to import XML documents into BaseX in one database, 
and populate a second database with a small amount of metadata about each 
document. This works but crashes every so often, and I have to restore the 
databases from backup and restart the import. To get through a large set of 
documents I now have the program create a backup (using the CREATE BACKUP 
command) after every 1000 documents imported.

Since my earlier post, I found that the connection between the client and 
server was occasionally being dropped. I've switched to opening and closing a 
connection for each document instead of using one long-running connection. The 
client and server are running on the same machine.

I'm using the latest version of BaseX (BaseX80-20141013.213520.zip). Here is 
the error message reported by my program when it crashes. The error occurs on 
the Query.execute() method of org.basex.examples.api.BaseXClient.java.

Improper use? Potential bug? Your feedback is welcome:
Contact: basex-talk@mailman.uni-konstanz.de
Version: BaseX 8.0 beta a91f5c2
Java: Oracle Corporation, 1.7.0_67
OS: Windows 7, amd64
Stack Trace:
java.nio.channels.OverlappingFileLockException
                at sun.nio.ch.SharedFileLockTable.checkList(Unknown Source)
                at sun.nio.ch.SharedFileLockTable.add(Unknown Source)
                at sun.nio.ch.FileChannelImpl.tryLock(Unknown Source)
                at 
org.basex.io.random.TableDiskAccess.lock(TableDiskAccess.java:139)
                at 
org.basex.io.random.TableDiskAccess.<init>(TableDiskAccess.java:87)
                at org.basex.data.DiskData.init(DiskData.java:119)
                at org.basex.data.DiskData.<init>(DiskData.java:80)
                at org.basex.core.cmd.Open.open(Open.java:70)
                at org.basex.core.cmd.Open.run(Open.java:36)
                at org.basex.core.Command.run(Command.java:360)
                at org.basex.core.Command.execute(Command.java:94)
                at org.basex.server.ClientListener.run(ClientListener.java:145)


The server instance reports the error with this stack trace:

C:\Programs\basex\basex\bin>basexhttp
BaseX 8.0 beta a91f5c2 [Server]
Server was started (port: 1984)
HTTP Server was started (port: 8984)
java.io.FileNotFoundException: 
C:\Programs\basex\basex\data\article_xml_meta\doc.basex (The requested 
operation cannot be performed on a file with a user-mapped section open
)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(Unknown Source)
        at java.io.FileOutputStream.<init>(Unknown Source)
        at org.basex.io.out.DataOutput.<init>(DataOutput.java:47)
        at org.basex.io.out.DataOutput.<init>(DataOutput.java:36)
        at org.basex.index.resource.Docs.write(Docs.java:73)
        at org.basex.index.resource.Resources.write(Resources.java:51)
        at org.basex.data.DiskData.write(DiskData.java:141)
        at org.basex.data.DiskData.flush(DiskData.java:249)
        at org.basex.data.DiskData.finishUpdate(DiskData.java:239)
        at org.basex.query.up.ContextModifier.apply(ContextModifier.java:124)
        at org.basex.query.up.Updates.apply(Updates.java:129)
        at org.basex.query.QueryContext.iter(QueryContext.java:351)
        at org.basex.query.QueryProcessor.iter(QueryProcessor.java:80)
        at org.basex.server.ServerQuery.execute(ServerQuery.java:128)
        at org.basex.server.ClientListener.query(ClientListener.java:492)
        at org.basex.server.ClientListener.run(ClientListener.java:109)



Here is the update statement where the error occurs, along with a bit of the 
surrounding Java.

BaseXClient.Query queryIndex = client.query("declare variable $indexDb 
external; declare variable $hash external; declare variable $database external; 
declare variable $path external; let $p := 
<properties><database>{$database}</database><path>{$path}</path><sha1>{$hash}</sha1><loadedDate>{current-dateTime()}</loadedDate></properties>
 return db:replace('" + indexDatabaseName + "', $path, $p)");
try {
                queryIndex.bind("$indexDb", indexDatabaseName);
                queryIndex.bind("$database", managedDatabaseName);
                queryIndex.bind("$path", path);
                queryIndex.bind("$hash", hash);
                queryIndex.execute();
} finally {
                queryIndex.close();
}

Previously this code used a variable for the first parameter of db:replace() 
but I changed it to "hard code" the database name into the query after reading 
about transactions and locking in the wiki. This change doesn't appear to have 
helped.

To put this in context, the above update is run after the XML document is 
imported using BaseXClient.replace(). The next thing that happens in the 
program is an XQuery db:replace to add more properties for the document to the 
metadata database.

I've added a Thread.sleep(300), to create a small delay between loading each 
document and this has helped the program to import more documents before 
crashing. Adjusting the delay doesn't seem to completely stop the crashes 
though.

I'm not sure if this is a bug or improper use. Any help would be appreciated.

Thanks,
Vincent







Reply via email to