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 7.0.2 #3581

Closed
michaelcsikos opened this issue Nov 20, 2023 · 14 comments · Fixed by #3597
Closed

Serious GraphMerger bug with 7.0.2 #3581

michaelcsikos opened this issue Nov 20, 2023 · 14 comments · Fixed by #3597
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.

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

Successfully merging a pull request may close this issue.

3 participants