Greetings,

I am currently using BaseX 7.7.2 on windows 7.

Periodically I get a corrupted database which topically manifests itself by the following message:

Improper use? Potential bug? Your feedback is welcome:
Contact: basex-talk@mailman.uni-konstanz.de
Version: BaseX 7.7.2
Java: Oracle Corporation, 1.7.0_45
OS: Windows 7, x86
Stack Trace:
java.lang.ArrayIndexOutOfBoundsException: 33
        at org.basex.io.random.TableDiskAccess.flush(TableDiskAccess.java:124)
        at org.basex.data.DiskData.finishUpdate(DiskData.java:212)
        at org.basex.core.cmd.Add.run(Add.java:109)
        at org.basex.core.Command.run(Command.java:345)
        at org.basex.core.Command.exec(Command.java:321)
        at org.basex.core.Command.execute(Command.java:78)
        at org.basex.server.LocalSession.execute(LocalSession.java:122)
        at org.basex.server.Session.execute(Session.java:37)
        at org.basex.core.Main.execute(Main.java:146)
        at org.basex.core.Main.execute(Main.java:130)
        at org.basex.core.Main.console(Main.java:90)
        at org.basex.BaseX.<init>(BaseX.java:168)
        at org.basex.BaseX.main(BaseX.java:38)

Once the database is corrupted there is no means to get the information back.
In order to restore a backup I have to manually shutdown running java processes to remove the locks.

I was able to narrow the circumstances of the corruption event to the following.
- The corruption occurs when adding a resource to the database
- The added resource needs to be big enough (one additional characher or xml node makes the difference)
- The database has to be in a certain state at the moment of the resource addition for the corruption to happen: the same resource added at a different time will note cause corruption
- The database could leave the 'pre-corruption' state if some activity happens


I was able to capture a database in 'pre-corruption' state in a backup, the database has no resources (all removed previously) and the backup is 44Kb
I also have an couple of XML files that cause corruption of this database when added both are 2kb.

I mostly experience the corruption when using db:add() or db:replace() functions in xqm files but in the example I managed to capture the corruption happens when issuing the add command in CLI as well.

I can provide the backup and XML files but I suppose that sending them to the list as attachments would not be welcomed.

I performed the same test with the same result on Linux:
- restaure the 'pre-corrupted' backup
- open the database
- add the XML file

Finally I performed the same tests with BaseX78-20140203.150949 and no corruption happened.


I'm seeking the most stable configuration for my application and therefore I would like to have Your opinion: Should I seek a workaround in BaseX 7.7.2 to avoid corruption or should I go with 7.8 in spite it being in beta stage?


TIA
Best regards