Forum Stats

  • 3,781,253 Users
  • 2,254,496 Discussions
  • 7,879,624 Comments

Discussions

putNoOverwrite dirties a secondary index

690755
690755 Member Posts: 18
edited Nov 10, 2009 2:48AM in Berkeley DB
Context: BDB v4.7.25, DPL through the Java API, replication subsystem enabled (thus with transactions, logging, etc.)

I encounter a strange behavior using putNoOverwrite on an existing entity with secondary keys.
One of the two secondary indexes declared in the entity gets broken.

Let me explain the case with an example.

The entity :
@Entity(version=0)
public class SomeEntity
{
@PrimaryKey
private int pk;

@SecondaryKey(relate=Relationship.MANY_TO_ONE, relatedEntity=AnotherEntity.class, onRelatedEntityDelete=DeleteAction.ABORT)
private int fk;

@SecondaryKey(relate=Relationship.MANY_TO_ONE)
private String state = "UNKNOWN";
}

The first put or putNoOverwrite is perfect:
putNoOverwrite(pk = 1, fk = 10, state = "OK")

My entity is present in DB, I can retrieve it through the secondary database "state" with the value "OK" (method SecondaryIndex.subIndex).

Then the faulty putNoOverwrite:
putNoOverwrite(pk = 1, fk = 10, state = "UNKNOWN")

This call should have no effect. In turn, my entity is still present in DB, and when I retrieve through is PK, I get it untouched.
But when I retrieve it through the secondary index "state" with value "OK" (method SecondaryIndex.subIndex), there is no match. The only secondary key present in the secondary index is "UNKNOWN".

I encounter this issue repeatedly.
Thanks for your help
Tagged:

Best Answer

  • 645330
    645330 Member Posts: 93
    Accepted Answer
    Hello. This bug has been fixed in the latest version of BDB (4.8.24.) The change log entry is item 1 in General Access Method Changes:
    http://www.oracle.com/technology/documentation/berkeley-db/db/programmer_reference/changelog_4_8.html

    You will need to upgrade BDB to fix this problem, as the patch has not been backported to version 4.7.

    Ben Schmeckpeper

Answers

  • 645330
    645330 Member Posts: 93
    Accepted Answer
    Hello. This bug has been fixed in the latest version of BDB (4.8.24.) The change log entry is item 1 in General Access Method Changes:
    http://www.oracle.com/technology/documentation/berkeley-db/db/programmer_reference/changelog_4_8.html

    You will need to upgrade BDB to fix this problem, as the patch has not been backported to version 4.7.

    Ben Schmeckpeper
  • 690755
    690755 Member Posts: 18
    Ben, thanks for your reply. I missed the release note entry. Shame that I didn't find any related issue in the forum.
This discussion has been closed.