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

Stateless update populates OneToMany with softdeleted records during serializing #2750

Closed
Ichtil opened this issue Jul 15, 2022 · 1 comment · Fixed by #2751
Closed

Stateless update populates OneToMany with softdeleted records during serializing #2750

Ichtil opened this issue Jul 15, 2022 · 1 comment · Fixed by #2751
Assignees
Labels
Milestone

Comments

@Ichtil
Copy link
Contributor

Ichtil commented Jul 15, 2022

Expected behavior

We have 2 entities - one has OneToMany to a second entity (that has soft delete).

After stateless DB.update() on first entity and serializing the same instance (eg. via Jackson serialization ObjectMapper), the entity gets serialized without soft deleted records.

Actual behavior

After calling DB.update(entity), ObjectMapper serializes the instance with soft deleted records.

Accessing the OneToMany relationship and checking its size makes this issue to "go away". (also demonstrated in the unit test).
The same happened when I was trying to debug this issue, this issue didn't show (presumably debugger accessed the property and loaded it correctly). Currently unsure whether emptiness of the collection plays a role (eg. if the collection is not empty then the bug would/wouldn't happen).

Also the the select for workflow_entity by its id does not check whether it is deleted - not sure if it's a problem, could be a separate issue.

Steps to reproduce

Please see attached PR with domain and unit test.

I have modified slightly the domain used in #2727 (thanks for fixing that one).

Entities extend HistoryColumns that extends BaseDomain. HistoryColumns add LazyLoaded reference which play role in the test failing - if they are eager loaded the bug does not happen.

@rbygrave rbygrave linked a pull request Jul 27, 2022 that will close this issue
@rbygrave rbygrave self-assigned this Jul 27, 2022
@rbygrave rbygrave added the bug label Jul 27, 2022
rbygrave added a commit that referenced this issue Jul 27, 2022
…ialisation)

The effective fix is in DLoadContext, only allow includeSoftDeletes to be set from
the query when the query is SpiQuery.Mode.NORMAL (not a lazy loading query).
@rbygrave
Copy link
Member

The effective fix is in DLoadContext, only allow includeSoftDeletes to be set from the query when the query is SpiQuery.Mode.NORMAL (not a lazy loading query).

Some background: We allow lazy loading softDeleted beans when they are single disconnected beans (e.g. from a L2 cache hit or in this case a stateless updated bean). What that lead to was this bug where that includeSoftDeletes propagates to the load context (DLoadContext) and instead we really only want includeSoftDeletes to propagates to DLoadContext when it's a top level query / the application code specified the query with includeSoftDeletes true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants