Forum Stats

  • 3,768,739 Users
  • 2,252,843 Discussions
  • 7,874,705 Comments

Discussions

Concurrency exception

francois.loison
francois.loison Member Posts: 3
edited Jun 24, 2017 10:21PM in Berkeley DB Java Edition

Hello,

My application is multi-threaded and writes concurrently entries.

Sometimes, method PrimaryIndex.put() crashes:

Caused by: java.lang.ArrayIndexOutOfBoundsException: 1

        at com.sleepycat.persist.impl.CollectionProxy.initializeProxy(CollectionProxy.java:48)

        at com.sleepycat.persist.impl.CollectionProxy$HashSetProxy.initializeProxy(CollectionProxy.java:83)

        at com.sleepycat.persist.impl.ProxiedFormat.writeObject(ProxiedFormat.java:137)

        at com.sleepycat.persist.impl.RecordOutput.writeObject(RecordOutput.java:116)

        at com.sleepycat.persist.impl.ReflectionAccessor$ObjectAccess.write(ReflectionAccessor.java:441)

        at com.sleepycat.persist.impl.ReflectionAccessor.writeNonKeyFields(ReflectionAccessor.java:278)

        at com.sleepycat.persist.impl.ComplexFormat.writeObject(ComplexFormat.java:604)

        at com.sleepycat.persist.impl.PersistEntityBinding.writeEntity(PersistEntityBinding.java:219)

        at com.sleepycat.persist.impl.PersistEntityBinding.objectToDataInternal(PersistEntityBinding.java:197)

        at com.sleepycat.persist.impl.PersistEntityBinding.objectToData(PersistEntityBinding.java:175)

        at com.sleepycat.persist.PrimaryIndex.put(PrimaryIndex.java:404)

Does somebody have a clue?

Thank you very much,

François

Answers

  • Greybird-Oracle
    Greybird-Oracle Member Posts: 2,690
    edited Jun 24, 2017 10:21PM

    Hello,

    From the stack trace, it looks like you have a field of type HashSet that is persistent, and the HashSet is being changed in one thread of your app, and written (PrimaryIndex.put) by another thread in your app.  In other words, one HashSet instance, or the entity object that contains it, is being accessed by multiple threads, and one thread is changing it while another is reading it.

    Note that this has nothing to do with database access or record locking. It only involves access to the HashSet (or entity object) instance. Normally, entity objects are not shared between threads. Are you sharing them explicitly between threads?

    --mark

This discussion has been closed.