Hello,

well I am using the latest version 9.1.2 which I downloaded a couple of days ago. I tried it both on Windows 10 and on Ubuntu 18.04, it shows the same behaviour. (sorry, I should have added these detail in the original email already...). The error first appeared way back with version 8.something, but I was unable to pinpoint it as it was very sporadic.
I attached a screenshot of how it looks like in basexgui right after step 8. I can reproduce it here anytime. I also tried creating the database via the GUI as well as using xquery, I also played with UPDINDEX and AUTOOPTIMIZE - it did not make any difference.
I also attached the broken databases, each with different indexing options as described.

From our Java application the error looks looks this, it is always at the very first query attempt after the databasse has corrupted:

Improper use? Potential bug? Your feedback is welcome:
Contact: basex-talk@mailman.uni-konstanz.de
Version: BaseX 9.1.2
Java: Oracle Corporation, 1.8.0_162
OS: Windows 10, amd64
Stack Trace: 
java.lang.ArrayIndexOutOfBoundsException: 2147483647
at org.basex.io.random.TableDiskAccess.fpre(TableDiskAccess.java:502)
at org.basex.io.random.TableDiskAccess.cursor(TableDiskAccess.java:453)
at org.basex.io.random.TableDiskAccess.read1(TableDiskAccess.java:151)
at org.basex.data.Data.kind(Data.java:304)
at org.basex.query.value.node.DBNode.<init>(DBNode.java:50)
at org.basex.query.value.seq.DBNodeSeq.itemAt(DBNodeSeq.java:70)
at org.basex.query.value.seq.DBNodeSeq.itemAt(DBNodeSeq.java:1)
at org.basex.query.value.seq.Seq$1.get(Seq.java:95)
at org.basex.query.iter.BasicIter.next(BasicIter.java:38)
at org.basex.query.expr.path.CachedPath.nodeIter(CachedPath.java:42)
at org.basex.query.expr.path.AxisPath.iter(AxisPath.java:66)
at org.basex.query.expr.path.AxisPath.iter(AxisPath.java:37)
at org.basex.query.func.fn.FnCount.item(FnCount.java:25)
at org.basex.query.expr.ParseExpr.iter(ParseExpr.java:48)
at org.basex.query.expr.constr.Constr.add(Constr.java:70)
at org.basex.query.expr.constr.CElem.item(CElem.java:93)
at org.basex.query.expr.constr.CElem.item(CElem.java:1)
at org.basex.query.expr.ParseExpr.iter(ParseExpr.java:48)
at org.basex.query.expr.constr.Constr.add(Constr.java:70)
at org.basex.query.expr.constr.CElem.item(CElem.java:93)
at org.basex.query.expr.constr.CElem.item(CElem.java:1)
at org.basex.query.expr.ParseExpr.value(ParseExpr.java:71)
at org.basex.query.expr.gflwor.Let$LetEval.next(Let.java:175)
at org.basex.query.expr.gflwor.GFLWOR$1.next(GFLWOR.java:88)
at org.basex.query.QueryContext.next(QueryContext.java:400)
at org.basex.query.scope.MainModule$1.next(MainModule.java:122)
at org.basex.core.cmd.AQuery.query(AQuery.java:111)
at org.basex.core.cmd.XQuery.run(XQuery.java:22)
at org.basex.core.Command.run(Command.java:257)
at org.basex.core.Command.execute(Command.java:93)
at org.basex.core.Command.execute(Command.java:116)



Am Do., 7. Feb. 2019 um 12:36 Uhr schrieb Christian Grün <christian.gruen@gmail.com>:
Hi Herbert,

First, thanks for the step-by-step procedure.

> now insert the same 2 documents in the opposite order
> 7: run insert_pigs.xq
> 8. run insert_plants.xq <-- this will trigger the error, the database is now garbage

My database is still valid after these steps (I can run queries and I
can export the full database). I also tried to swap step 7 and 8 (that
would probably be the opposite order you mentioned?).

This is what I did:
1a. download and unzip BaseX91.zip
1b. start bin/basexgui from the unzipped directory
2. create an empty TEST database via the GUI dialog (and, in the
second run, by running db:create('TEST').
3. run ...etc

Some question in return:

• How do you detect that your database is garbage after the last step?
• Does this also happen with a fresh installation of BaseX (did you
change the default options)?
• I made no difference in my tests, but how did you create the
database? Did you use the GUI features, or did you run
db:create('TEST') ?
• Could you experience the same behavior on command line?

Cheers
Christian