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

Serious GraphMerger bug with 8.2.7 #3581

Open
michaelcsikos opened this issue Nov 20, 2023 · 22 comments · Fixed by #3597 or #4333
Open

Serious GraphMerger bug with 8.2.7 #3581

michaelcsikos opened this issue Nov 20, 2023 · 22 comments · Fixed by #3597 or #4333
Assignees
Labels

Comments

@michaelcsikos
Copy link

It looked like the GraphMerger problems had been resolved, but since Friday I have been trying to work this one out. I have managed to strip down an example to just two tests, one which shows the expected result using just SaveAsync(), and the failure with SaveAndMergeAsync(). The only difference between the two tests is how the save is performed:

if (merge)
    await instance.SaveAndMergeAsync();
else
    instance = await instance.SaveAsync();

GraphMergerTest.zip

Open the Test Explorer and run WidgetTests. UpdateWithMergeWidgetTest will fail, and UpdateWithoutMergeWidgetTest should pass.

In the Standard Output, you'll see that one of the child items has been incorrectly merged in, there is a duplicate Guid, and one of them has been lost. It is usually the last item which is a duplicate of the second.

This is a show stopper for us currently. I could roll back to 6.2.2, but this would require a fair bit of reworking as the Blazor view model methods changed in 7.0.0. I would really appreciate someone looking into this.

@rockfordlhotka
Copy link
Member

rockfordlhotka commented Nov 20, 2023

Adding a reference to the PR that (theoretically) fixed this issue:

#3481

@rockfordlhotka
Copy link
Member

fyi, I'm in Prague this week speaking at a conference and otherwise on holiday, so it won't be until sometime next week when I am likely to get a chance to look into this.

@russblair might have an idea, as he dug into the #3481 issue in depth.

@russblair
Copy link
Contributor

I will try to take a look at this later today or tomorrow.

@russblair
Copy link
Contributor

As far as we can tell, the bug is not in the GraphMerge logic but is in the DataPortal logic. The bug is identified after the FetchAsync in the Fetch method on line 118 of the SimpleDataPortal.cs. The obj.Instance identity manager has the incorrect next identity value. We are unclear as to how this is happening or how to narrow it down further.

@michaelcsikos
Copy link
Author

DoesSaveAndMergeAsync end up calling Fetch?

@rockfordlhotka
Copy link
Member

It does not call Fetch. It calls Update, gets the result, and merges the result with the original graph.

@russblair
Copy link
Contributor

We think we have a working solution. Check it out at https://github.com/russblair/csla/tree/RB/v7.0.3_IdentityManagerIssue%233581.

@russblair
Copy link
Contributor

I did not raise a PR because we have added Michael's test code to the project and I wanted to make sure that was ok with both of you (Micael and Rocky) first.

@michaelcsikos
Copy link
Author

That's fine. I have never written a test like this before and have been developing with CSLA for 16 years. I was pleased to discover it was reproducible in a test and not just in Blazor.

@rockfordlhotka
Copy link
Member

More tests are good!!

@rockfordlhotka
Copy link
Member

@russblair can you create a PR against main as well so this fix gets into CSLA 8 and future versions?

@russblair
Copy link
Contributor

russblair commented Nov 30, 2023 via email

@rockfordlhotka
Copy link
Member

@michaelcsikos and @russblair I have pushed a prerelease of 7.0.3 to nuget, so if you can try that version to ensure it fixed the issue I think we'll be all set.

@michaelcsikos
Copy link
Author

The 7.0.3 prerelease looks good.

Copy link

github-actions bot commented Jun 2, 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 Jun 2, 2024
@michaelcsikos
Copy link
Author

Yesterday, I ran into this problem again in CSLA 8.2.7. The difference is when the child collection is more deeply nested in the object graph.

I have updated my original GraphMergerTest to use

Root
  - Branch
    - Leafs
      - Leaf

See the attached GraphMergerRootBranchLeafTest solution. Open the Test Explorer and run the tests. UpdateWithMergeWidgetTest will fail, and UpdateWithoutMergeWidgetTest should pass.

Hopefully, this is a simple fix.

GraphMergerRootBranchLeafTest.zip

@michaelcsikos michaelcsikos reopened this Oct 4, 2024
@michaelcsikos michaelcsikos changed the title Serious GraphMerger bug with 7.0.2 Serious GraphMerger bug with 8.2.7 Oct 4, 2024
@michaelcsikos
Copy link
Author

Fortunately, in our Blazor app we can use a workaround for now: VM.Model = VM.Model.SaveAsync() instead of VM.SaveAsync(). However, the user experience is not as pleasant as the UI resets, which is more noticeable with a tabbed interface.

@michaelcsikos
Copy link
Author

@rockfordlhotka, @russblair Did you see I reopened this issue?

@russblair
Copy link
Contributor

Unfortunately, I haven't had a chance to look at this yet. I have added this to my to do list.

@StefanOssendorf
Copy link
Contributor

I'll work on this issue starting today

StefanOssendorf added a commit that referenced this issue Nov 20, 2024
…gement the next identity value will be unique within the collection.

Fixes #3581
rockfordlhotka pushed a commit that referenced this issue Nov 21, 2024
…gement the next identity value will be unique within the collection. (#4333)

Fixes #3581
@github-project-automation github-project-automation bot moved this from In Progress to Done in CSLA Version 8.2.8 Nov 21, 2024
@rockfordlhotka
Copy link
Member

@StefanOssendorf can you apply this to 8.2.x as well please?

@rockfordlhotka rockfordlhotka moved this from Done to In Progress in CSLA Version 8.2.8 Nov 21, 2024
StefanOssendorf added a commit that referenced this issue Nov 21, 2024
…identity management the next identity value will be unique within the collection.

Fixes #3581
@StefanOssendorf
Copy link
Contributor

@StefanOssendorf can you apply this to 8.2.x as well please?

It's up :)

rockfordlhotka pushed a commit that referenced this issue Nov 22, 2024
…identity management the next identity value will be unique within the collection. (#4335)

Fixes #3581
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Status: In Progress
4 participants