Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another ArrayIndexOutOfBoundsException #68

catbref opened this issue Nov 30, 2017 · 1 comment


None yet
1 participant
Copy link

commented Nov 30, 2017

2017-11-11 09:46:30 INFO  Controller:890 - received new valid block
2017-11-11 09:52:04 ERROR Controller:1037 - 136
java.lang.ArrayIndexOutOfBoundsException: 136
	at org.mapdb.Volume$ByteBufferVol.getDataInput(
	at org.mapdb.Volume$ByteBufferVol.getDataInput(
	at org.mapdb.StoreWAL.get2(
	at org.mapdb.StoreWAL.get(
	at org.mapdb.Caches$HashTable.get(
	at org.mapdb.BTreeMap.get(
	at org.mapdb.BTreeMap.containsKey(
	at database.DBMap.contains(
	at database.DBMap.contains(
	at qora.block.Block.getHeight(
	at qora.block.Block.orphan(
	at qora.Synchronizer.synchronize(
	at qora.Synchronizer.synchronize(
	at controller.Controller.update(
2017-11-11 09:52:04 WARN  Network:117 - Connection error : / : 136
2017-11-11 09:52:04 INFO  Controller:193 - STATUS OK
| Last Block Signature: F2s97G7FKrt5B2Ld7sBos3MAGHwJxjz4yqMogft4Rdhst8rTExXchFxSKURFeFbpUDuByDNj97EiBMv25DHPa4i2d4bA5hZCp2tcP9GFs57F4o3LgT63UonmLipYH67e9L3VzT2jYLh97QuvyrfDwUuTX3smM5qhXajFQVHe4NjS866
| Last Block Height: 408875
| Last Block Time: 11/11/2017 9:46:30 AM
| Last Block Found 5m 34s ago.

@catbref catbref added bug mapdb labels Dec 1, 2017


This comment has been minimized.

Copy link
Collaborator Author

commented Dec 6, 2017

Working backwards from innermost stack frame:


        public final DataInput2 getDataInput(long offset, int size) {
            return new DataInput2(chunks[(int)(offset >>> chunkShift)], (int) (offset&chunkSizeModMask));

offset >>> chunkShift equates to 136, which is the non-existent array index in chunks.
chunkShift seems to be 20 so chunks are 1MB in size?

So the offset is wrong when passed at mapdb/

            DataInput2 in = (DataInput2) log.getDataInput(r[0]&LOG_MASK_OFFSET, size);

r[0] comes from the modified transaction HashMap (lines 333-334):

        //check if record was modified in current transaction
        long[] r = modified.get(ioRecid);

Is modified somehow out of sync?

  • cleared in reloadIndexFile but this shouldn't cause the issue above where there is a record
  • set to PREALLOC in preallocate() but also shouldn't cause issue above
  • set in put() line 228
  • set in update() line 416
  • set in compareAndSwap() line 477
  • "tombstoned" in delete() line 528

Is the log ByteBufferVol corrupted/reset outside of a write-lock by another thread?

  • logReset() only checks for structuralLock
  • logReset() called by:
    • rollback() - under full write locks
    • replayLogFile() twice - called by commit() - under full write locks
    • StoreWAL constructor

Does this situation only occur on Windows and hence something to do with mmap/Windows caching?

Is it possible to store more than chunkSize in a chunk when ByteBufferVol should put extra bytes into next chunk? (Maybe add assert()s to mapdb/ to test this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.