Hello,

I want to ask for help debugging an issue:

On January I updated Cayenne from 4.2.RC1 to 4.2.RC2.
Immediately after that, we had an issue of objects not being persisted to the 
db; an http endpoint on our service accepts a batch of records and creates 
objects to save:

ObjectContext ctx = server.newContext();

for (Aggregation post : request.getEntries()) {

        MyDataObject dbo = ctx.newObject(MyDataObject.class);

        dbo.setValueDate(post.getValueDate());

        dbo.setVersion(post.getVersion());

        dbo.setUuid(post.getUuidBytes());

                        ... etc ...
        }

try {

        ctx.commitChanges(); 


The endpoint is called with up to 250 items at a time, and we store ~4000 on 
each daily run of that job.
We found that after the update, a small number, like 2 sometime more, records 
would be missing from the db, but not always.


Rolling back seemed to solve the issue. Puzzled, I tried git bisecting Cayenne 
from RC1 to RC2.
This is was the result:


7bc235f92e2e61d3f4f04d3bebb65a1756d2e092 is the first bad commit
commit 7bc235f92e2e61d3f4f04d3bebb65a1756d2e092
Author: Nikita Timofeev <stari...@gmail.com>
Date:   Mon Nov 21 12:59:45 2022 +0300

    CAY-2777 Reverse relationship is not set with single table inheritance

 .../access/flush/DefaultDataDomainFlushAction.java |   3 +-
 .../apache/cayenne/access/flush/EffectiveOpId.java |   2 +-
 .../access/flush/operation/OpIdFactory.java        | 113 ++++++++++++++++++
 .../org/apache/cayenne/map/ObjRelationship.java    |  13 +-
 .../java/org/apache/cayenne/ManyToManyJoinIT.java  |  27 +++++
 .../SelfRelationship.java                          |  28 +++++
 .../SelfRelationshipSub.java                       |  28 +++++
 .../auto/_Author.java                              |   7 +-
 .../auto/_SelfRelationship.java                    | 132 +++++++++++++++++++++
 .../auto/_SelfRelationshipSub.java                 |  91 ++++++++++++++
 .../auto/_Song.java                                |  10 +-
 .../relationships-many-to-many-join.map.xml        |  37 +++++-
 12 files changed, 472 insertions(+), 19 deletions(-)
 create mode 100644 
cayenne-server/src/main/java/org/apache/cayenne/access/flush/operation/OpIdFactory.java
 create mode 100644 
cayenne-server/src/test/java/org/apache/cayenne/testdo/relationships_many_to_many_join/SelfRelationship.java
 create mode 100644 
cayenne-server/src/test/java/org/apache/cayenne/testdo/relationships_many_to_many_join/SelfRelationshipSub.java
 create mode 100644 
cayenne-server/src/test/java/org/apache/cayenne/testdo/relationships_many_to_many_join/auto/_SelfRelationship.java
 create mode 100644 
cayenne-server/src/test/java/org/apache/cayenne/testdo/relationships_many_to_many_join/auto/_SelfRelationshipSub.java

I also tried reverting this commit on top of RC2 and that also seems to have 
solved it.

The entity is quite simple, no relationships at all.
The database is MySQL 8.
The PK is regular mysql generated ID:

                <db-attribute name="id" type="BIGINT" isPrimaryKey="true" 
isGenerated="true" isMandatory="true" length="20"/>

I can share more info, code etc, with someone who wants help debugging it, but 
can not expose too much company info here, sorry.
It is of course possible that the bug is outside Cayenne, on our code, db, etc, 
and somehow only triggered if that commit is present.
I can not say with 100% certainty that it is an issue with Cayenne.

The issue is sporadic, but quite frequent. If there are any ideas on how I can 
further debug this, do let me know.

Thanks for the attention given, I really would like to get the bottom of this.

Kind regards,

Henrique Gomes



Reply via email to