ObjectDB ObjectDB

Intermittent: "Attempt to reuse an existing primary key value" when persisting a new instance



  I don't have a useful test case to expose this issue, but I am getting an intermittent "Attempt to reuse an existing primary key value". In this particular instance, the error is:

Attempt to reuse an existing primary key value (com.x.y.z.UserPassword:1) (error 642)

at com.objectdb.jpa.EMImpl.beforeCompletion(EMImpl.java:338)
        at com.sun.enterprise.transaction.JavaEETransactionImpl.commit(JavaEETransactionImpl.java:453)
        at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:857)
        at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5115)        at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4880)        at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2039)
        at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1990)
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)


The attempted PK value to be re-used was '1', but the actual last object created has an id of 168,000. I've inserted 168,000 objects of dummy data with an importer. A subsequent 'submit' again of cleared up the issue. As I assign no ID's in my GUI - it seems that there could be a small bug? I'm using the following annotations for the id:


    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="user_pwd_seq")
    @SequenceGenerator(name="user_pwd_seq", initialValue=1,allocationSize=1)


I realise that due to the lack of a reusable test that the issue is hard to track. It must be a really small bug as it hardly ever happens (maybe once a week during dev). This issue only happens when saving new items, never while updating an existing entity. I'm still working on trying to make a repeatable test, but due to the frequency of occurrence, I doubt that a specific test will be able to expose the issue.




ObjectDB Version: 2.2.8_05


This might be related to a bug that was fixed in build 2.2.8_06. Please check that new build.

ObjectDB Support


To post on this website please sign in.