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

GraphMerge loses child objects #3481

Closed
russblair opened this issue Oct 5, 2023 · 1 comment · Fixed by #3483
Closed

GraphMerge loses child objects #3481

russblair opened this issue Oct 5, 2023 · 1 comment · Fixed by #3483
Assignees
Labels

Comments

@russblair
Copy link
Contributor

I discovered a strange bug where the last row of an ECL disappears after calling SaveAsync. I discovered this in CSLA 7 using Blazor however I suspect it affects CSLA 6 as well.
This strange occurrence is caused by a GraphMerge failure following a successful save. This puts the object in an invalid state and cannot be used without risk of corrupting data in the database. We have added logic to detect this scenario during the save and in some cases, have to navigate the user away from the page so the object can be reloaded.
I showed the issue to Andrew (The Cake Monster) and my co-worker Will. Andrew showed me that the Graph Merge unit test were failing and Will confirmed that the bug is in CLSA and not the unit tests.
Due to the nature of the symptoms, I suspect that the bug was introduced when the MobileFormatter was switched to the new binary serializer.
The bug appears to be that the deserialization process assigns different values to the objects in the object graph then were in the original. I think this is because the binary serializer restores the original identity value so there is no need to recalculate them. I suspect the old serializer didn’t preserve the identity value.
I initially tried removing line 31 from IdentityManager.cs which helped but still some unit tests were failing. Will was able to provide additional code changes to get the unit tests to pass.
Scenarios and problems we found in the GraphMerge unit tests are:

  1. When an object is cloned, the deserialization process restores the object's identity. In some cases, following deserialization, SetParent is called which changes the identity. My understanding is the cloned object should have the same identities as per unit tests.
  2. We discovered another case related to 1 above, where the parent should be changed but not the identity as per unit tests.
  3. During a save, after the object is cloned, the ApplicationContext is set which changes the object's identity. We know that an object's identity must remain intact after a save as per unit tests.
  4. During a GraphMerge, when a target child is updated to a source child, the source child parent is not updated to the target child parent. As per unit tests, the source child parent should be changed.
    Assuming the introduction of the MobileFormatter was the cause, we are uncertain whether fixing the above scenarios is the correct action to take or whether changing the MobileFormatter to behave in the same way the previous Formatter did, with respect to identity & parents, makes more sense.
russblair added a commit to russblair/csla that referenced this issue Oct 5, 2023
@rockfordlhotka rockfordlhotka moved this to In Progress in CSLA Version 7.0.1 Oct 5, 2023
@rockfordlhotka rockfordlhotka moved this to In Progress in CSLA Version 8.0.0 Oct 5, 2023
russblair added a commit to russblair/csla that referenced this issue Oct 5, 2023
rockfordlhotka added a commit that referenced this issue Oct 5, 2023
#3481 Fixed IdentityManage.GetNextIdentity method
@rockfordlhotka rockfordlhotka moved this from In Progress to Done in CSLA Version 7.0.1 Oct 5, 2023
rockfordlhotka added a commit that referenced this issue Oct 5, 2023
#3481 Fix GraphMerge issue with losing child objects
@github-project-automation github-project-automation bot moved this from In Progress to Done in CSLA Version 8.0.0 Oct 5, 2023
russblair added a commit to russblair/csla that referenced this issue Dec 20, 2023
Copy link

github-actions bot commented Apr 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants