-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use ContentManagerSession in GetMany #8705
base: 1.10.x
Are you sure you want to change the base?
Use ContentManagerSession in GetMany #8705
Conversation
@BenedekFarkas forgot to tag you in the main post |
I'll need a few days to get down to testing it properly, but it looks good on first glance! |
@BenedekFarkas I just realized this is still open. My tests still look good, But I'm still not too fond of the code I wrote. |
Well, DefaultContentManager is very old, so there's probably a lot of stuff we could refactor (which sort of affects what you can achieve there). I wouldn't merge it without unit/Spec testing completing on it first but being able to run tests is still blocked by me (#8686). We could also add some specific tests to verify this change, if necessary. |
…t_many_skip_queries
this is targeted at 1.10.x, so I think specflows should be able to run... I'll get back to you on this. |
I merged the latest 1.10.x into the branch for this PR and I was able to run all specflows. |
…t_many_skip_queries
…onal duplicate queries
I'm still not 100% on this solution. |
I think if you see that it consistently reduces the number of queries, that's already a win. Did you test with SysCache enabled?
Doesn't the current logic handle that situation just by nature of running as if there were more? BTW ContentManager.Get uses ContentManagerSession already, so it's possible to short-circuit to call that, if necessary. |
…_many_skip_queries
@MatteoPiovanelli please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement ( “Agreement” ) is agreed to by the party signing below ( “You” ), 1. Definitions. “Code” means the computer software code, whether in human-readable or machine-executable form, “Project” means any of the projects owned or managed by .NET Foundation and offered under a license “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any “Submission” means the Code and any other copyrightable material Submitted by You, including any 2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any 3. Originality of Work. You represent that each of Your Submissions is entirely Your 4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else 5. Licenses. a. Copyright License. You grant .NET Foundation, and those who receive the Submission directly b. Patent License. You grant .NET Foundation, and those who receive the Submission directly or c. Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement. 6. Representations and Warranties. You represent that You are legally entitled to grant the above 7. Notice to .NET Foundation. You agree to notify .NET Foundation in writing of any facts or 8. Information about Submissions. You agree that contributions to Projects and information about 9. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and 10. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and .NET Foundation dedicates this Contribution License Agreement to the public domain according to the Creative Commons CC0 1. |
I merged the latest 1.10.x inside the pr branch. Example case: TaxonomyField. Orchard/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyFieldDriver.cs Line 89 in 5c3d045
following to
Orchard reads the selected terms for current content item. Since there is no QueryHint, the data from TermPartRecord (i.e. term path) isn't loaded, so it stays empty and gets stored in session this way. Since GetMany function doesn't read that term anymore in the future (as it is saved inside the session), path doesn't get to be corrected anymore (previously - and it is "luck" - after the GetAppliedTerms call, the GetTerms overwrote the terms inside the session with the proper QueryHints (
This issue raises and exception when sorting terms (here:
It's not so easy to explain, but I hope I have been clear. Simple way to reproduce the error is to add a TaxonomyField to a content item, select a term, save and, when loading the editor, it crashes and no TaxonomyField is displayed. |
This is the first hacky attempt. I'm not satisfied with the code: I look at it and it feels like it's doing some stuff too many times where it shouldn't.
Anyway, it does reduce the number of repeated calls to the database. In some setups, that may become significant.
I haven't had a chance to properly test this, or measure the timing performance, to make sure that we aren't losing time in the work we do to avoid calls to the db.
To summarize, my concerns with my code in this PR right now: