Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data loss after update to Quarkus 1.10.5 #14201

Closed
bobbyphilip opened this issue Jan 8, 2021 · 8 comments · Fixed by #14907
Closed

Data loss after update to Quarkus 1.10.5 #14201

bobbyphilip opened this issue Jan 8, 2021 · 8 comments · Fixed by #14907
Labels
area/hibernate-orm Hibernate ORM kind/bug Something isn't working
Milestone

Comments

@bobbyphilip
Copy link
Contributor

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.

@bobbyphilip bobbyphilip added the kind/bug Something isn't working label Jan 8, 2021
@ghost ghost added the triage/needs-triage label Jan 8, 2021
@geoand
Copy link
Contributor

geoand commented Jan 11, 2021

cc @Sanne

@Sanne Sanne added area/hibernate-orm Hibernate ORM and removed triage/needs-triage labels Jan 11, 2021
@bobbyphilip
Copy link
Contributor Author

@Sanne Any clues on why this could happen?

@matus-m
Copy link

matus-m commented Jan 28, 2021

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.

@Sanne
Copy link
Member

Sanne commented Jan 28, 2021

Sorry I missed this, too much going on. I'll need to ask my teammates for help.

@dreab8 / @beikov could one of you please have a look? Looks like an NPE on the new BitSets code.

@matus-m
Copy link

matus-m commented Jan 28, 2021

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.

@dreab8
Copy link
Contributor

dreab8 commented Jan 28, 2021

Thanks @yntelectual for the reproducer, I'm going to give a look at it.

@bobbyphilip
Copy link
Contributor Author

@yntelectual Thanks for confirming this issue. I thought I was going crazy.

@dreab8
Copy link
Contributor

dreab8 commented Jan 29, 2021

Opened a Jira https://hibernate.atlassian.net/browse/HHH-14424, working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants