Issue #625: ArrayIndexOutOfBoundsException: -1

Type: Bug ReoprtPriority: CriticalStatus: FixedReplies: 3
#1

I've attached a test which fails with the error "ArrayIndexOutOfBoundsException: -1". It runs 10 threads which create and persist objects. The objects are based on application objects so its not a single class test I'm afraid but it is standalone. I'm running as follows: java -classpath objectdb.jar;test.jar PersistTest

I've attached the test jar, a jar containing the source and the odjectdb.conf.

Unfortunately the problem occurs inconsistently - sometimes it will fail almost immediately, sometimes it will run for a couple of minutes - so is most likely connected to the multiple threads. I haven't been able to narrow it down further so I'm hoping you see the same behaviour from the example.

I'm running with 64bit JVM 1.6.0_30 on windows 7

The first thread to fail output the following stacktrace:

java.lang.ArrayIndexOutOfBoundsException: -1
        at com.objectdb.o.HTB.t(HTB.java:448)
        at com.objectdb.o.PGC.B(PGC.java:403)
        at com.objectdb.o.SFL.ah(SFL.java:991)
        at com.objectdb.o.SFL.run(SFL.java:899)
        at java.lang.Thread.run(Unknown Source)

Subsequent threads fail with the followin stacktrace:

[ObjectDB 2.3.5_04] javax.persistence.PersistenceException
Attempt to commit a transaction after failure in writing to database file 'C:\Users\Home\workspace\Object.Test\test\persistTest.odb' (error 144)
        at PersistTest$ErrorThread.run(PersistTest.java:97)
Caused by: com.objectdb.o.UserException: Attempt to commit a transaction after failure in writing to database file 'C:\Users\Home\workspace\Object.Test\test\persistTest.odb'
        at com.objectdb.o.MSG.d(MSG.java:74)
        at com.objectdb.o.SFL.ad(SFL.java:823)
        at com.objectdb.o.MST.ad(MST.java:1327)
        at com.objectdb.o.MST.Va(MST.java:1230)
        at com.objectdb.o.WRA.Va(WRA.java:355)
        at com.objectdb.o.WSM.Va(WSM.java:146)
        at com.objectdb.o.OBM.bK(OBM.java:945)
        at com.objectdb.o.OBM.bH(OBM.java:818)
        at com.objectdb.o.OBM.flush(OBM.java:739)
        ... 1 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
        at com.objectdb.o.HTB.t(HTB.java:448)
        at com.objectdb.o.PGC.B(PGC.java:403)
        at com.objectdb.o.SFL.ah(SFL.java:991)
        at com.objectdb.o.SFL.run(SFL.java:899)
        at java.lang.Thread.run(Unknown Source)

Please let me know if you need any further information.

 

#2

Thank you very much for this useful test.

It also reproduces other exceptions that have been reported by you (issues #610, #621).

Please try build 2.3.5_05 that should fix all these issues.

ObjectDB Support
#3

Great - thanks.

Do you have any more detail on the specifics of the problem? I'm keen to make my test more robust and target the issue directly if possible.

#4

It was a bug in the page cache.

This cache can hold several different versions of the same database page (representing pages that were modified by different transactions) and it should serve the right version of every page for every user (depending when the operation has started). You cannot disable that cache since it has a minimum size even if you request zero size.

In some situations (e.g. when using flush that is followed by other operations and then commit) - the page cache could purge newer version of a page leaving older versions for use by newer users. The result is catastrophic, since a new transaction may commit mixed old and new pages. Therefore it could corrupt the database, as demonstrated by your test. Consequently many types of unexpected exceptions (including ArrayIndexOutBoundsException) can be thrown.

The ObjectDB storage engine (including the page cache) is tested with 100% line coverage, but apparently this is not sufficient, since these tests do not cover all the possible scenarios, as your test showed.

ObjectDB Support

Reply