Data loss after update to Quarkus 1.10.5
bobbyphilip opened this issue ยท 8 comments
I was running on Quarkus 1.9.1. I recently updated directly to 1.10.5
I started seeing some db entries get wiped out, when accessing a related table.
I have been able to reproduce it in my environment with a simple db read now.
I use postgres, panache, hibernatesearch among other extensions.
It basically boils down to something like
@Entity
@RegisterForReflection
@Table(name = "books")
@Indexed
public class Book extends PanacheEntityBase implements Serializable {
//various fields...
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(updatable = false, name = "shop_id")
@JsonbTransient
private Shop shop;
}
What happens is when I call Book.findById(
), the data in the corresponding Shop entity gets set to null.
I am not sure if there is something wrong, in the way I have written the entity, but this used to work in 1.9
I then took Quarkus v1.10.3
I now get an exception in the same sequence.
14:01:19.625 WARN [co.ar.at.arjuna] beforeCompletion ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple< 0:ffffc0a80e70:adb1:5ff8578d:8, org.hibernate.resource.transaction.backend.jta.internal.synchronization.RegisteredSynchronization@147062e3 >: java.lang.NullPointerException
at org.hibernate.persister.entity.AbstractEntityPersister.lambda$resolveDirtyAttributeIndexes$0(AbstractEntityPersister.java:2282)
at java.base/java.util.BitSet$1BitSetSpliterator.forEachRemaining(BitSet.java:1283)
Since the transaction fails, I dont have data loss, but looks like something is trying to overwrite the shop entity
Commenting out the Shop entity from Book, causes everything to work ok, in both versions
I have tracked down the change in behaviour to the CRM changes in 1.10.4
I have been able to reproduce this reliably in my environment, but havent been able to create a standalone example.
@Sanne Any clues on why this could happen?
I experience the same issue. It occurs if a method that performs the select is @Transactional
and does not load the full entity tree -i.e. some lazy association is not loaded. Then the hibernate will trigger an updateAction in the doFlush
handler, and will try to make an update on the not-loaded entity, setting all its fields to null
except id
. The same behaviour is in 1.11.1 but I too have not yet been able to reproduce it in a simple new project(the project where it happens every time is a fairly complex). Will report back when I managed to prepare a reproduction case.
I managed to create a repro case https://github.com/yntelectual/quarkus-bug-14201 along with a small readme, but it is really weird: there are several ways how to avoid the bug behaviour e.g. removal of a lazy association, removal of attribute in parent class ๐ฑ.. so it feel pretty strange. Looking forward to any result.
Thanks @yntelectual for the reproducer, I'm going to give a look at it.
@yntelectual Thanks for confirming this issue. I thought I was going crazy.
Opened a Jira https://hibernate.atlassian.net/browse/HHH-14424, working on it.