I ran a load test overnight on my JPOS system and in the morning noticed the following in the logs:
java.lang.ArrayIndexOutOfBoundsException: 310287
at jdbm.recman.TransactionManager.start(TransactionManager.java:295)
at jdbm.recman.RecordFile.commit(RecordFile.java:239)
at jdbm.recman.PageManager.commit(PageManager.java:230)
at jdbm.recman.BaseRecordManager.commit(BaseRecordManager.java:428)
at jdbm.recman.CacheRecordManager.commit(CacheRecordManager.java:341)
at org.jpos.space.JDBMSpace.inp(JDBMSpace.java:305)
at org.jpos.space.SpaceUtil.nextLong(SpaceUtil.java:78)
I was able to attach to the application with the debugger and figured out that the problem was that the curTxn field of TransactionManager has a value > 300000 which is a bit larger than the length of the txns array.
The only theoretical way I can see this actually occurring is if a single TransactionManager has start() called by multiple threads, but looking a bit closer at the code I don't see how this could happen????? I can see that TransactionManager is not thread safe, and I am guessing this is a design choice. But I also see that all uses of TransactionManager are made in a synchronised manner, i.e. access to BaseRecordManager which has a RecordFile is synchronised.
I really don't know what happened to get into this state but I will be running the load test again tonight to see if I can replicate it.
Hopefully you might be able to shed some light on the problem