Skip to content

BeforeRecordCreateListener does not update index #807

Description

@vic0824

ArcadeDB Version: v23.1.2-SNAPSHOT (build 75a9319/1674650185130/main)

JDK Version: openjdk 11.0.12 2021-07-20 LTS

OS: CentOS release 6.9 (Final)

Expected behavior

when a BeforeRecordCreateListener sets the value of a property, the corresponding index is updated

Actual behavior

When the listener is invoked, the value of the property is correctly set, but the corresponding value in the index is null.
As a consequence, the next time a record is updated, a DuplicatedKeyException is thrown

Steps to reproduce

Executing the attached testBeforeRecordCreateListenerWithIndex test case, produces the following output:

INSERT INTO Order SET status = ?, processor = ?, parameters: [PENDING, SIR1LRM-7.1]
result = {"status":"PENDING","processor":"SIR1LRM-7.1","id":1,"@cat":"d","@type":"Order","@rid":"#1:0"}
INSERT INTO Order SET status = ?, processor = ?, parameters: [PENDING, SIR1LRM-7.1]
result = {"status":"PENDING","processor":"SIR1LRM-7.1","id":2,"@cat":"d","@type":"Order","@rid":"#2:0"}
UPDATE Order SET status = ? RETURN AFTER WHERE id = ?, parameters: [ERROR, 1]
result = {"status":"ERROR","processor":"SIR1LRM-7.1","id":1,"@cat":"d","@type":"Order","@rid":"#1:0"}
UPDATE Order SET status = ? RETURN AFTER WHERE id = ?, parameters: [ERROR, 2]
result = {"status":"ERROR","processor":"SIR1LRM-7.1","id":2,"@cat":"d","@type":"Order","@rid":"#2:0"}
Duplicated key [ERROR, null] found on index 'Order[status,id]' already assigned to record #1:0
SELECT id, status from Order
result = {"id": 1, "status": "ERROR"}
result = {"id": 2, "status": "PENDING"}
com.arcadedb.exception.DuplicatedKeyException: Duplicated key [ERROR, null] found on index 'Order[status,id]' already assigned to record #1:0
	at com.arcadedb.database.TransactionIndexContext.checkUniqueIndexKeys(TransactionIndexContext.java:338)
	at com.arcadedb.database.TransactionIndexContext.checkUniqueIndexKeys(TransactionIndexContext.java:373)
	at com.arcadedb.database.TransactionIndexContext.commit(TransactionIndexContext.java:162)
	at com.arcadedb.database.TransactionContext.commit1stPhase(TransactionContext.java:479)
	at com.arcadedb.database.TransactionContext.commit(TransactionContext.java:114)
	at com.arcadedb.database.EmbeddedDatabase.lambda$commit$2(EmbeddedDatabase.java:366)
	at com.arcadedb.database.EmbeddedDatabase.executeInReadLock(EmbeddedDatabase.java:1326)
	at com.arcadedb.database.EmbeddedDatabase.commit(EmbeddedDatabase.java:361)
	at com.arcadedb.server.ServerDatabase.commit(ServerDatabase.java:128)
	at eu.serco.csrs.persistence.ArcadeDBTest.testBeforeRecordCreateListenerWithIndex(ArcadeDBTest.java:159)
	at eu.serco.csrs.persistence.ArcadeDBTest.main(ArcadeDBTest.java:65)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions