-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Optimize IndexingContentHandlers perf #13721
Conversation
I haven't changed the rebuildindex function yet, so let's see if I got it right here |
I'm surprised it is broken. Will test it and analyze the PR. |
This pull request has merge conflicts. Please resolve those before requesting a review. |
Do you want to get back to this, @Skrypt? |
Index Latest option is working on main branch. No issue there. I think that this PR will break it though. It may fix performance issues. We need to make sure that the PreviousItem and ContentItem from the Context is never altered. |
src/OrchardCore.Modules/OrchardCore.Search.Lucene/Handler/LuceneIndexingContentHandler.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Search.Lucene/Handler/LuceneIndexingContentHandler.cs
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Search.Lucene/Handler/LuceneIndexingContentHandler.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Search.Lucene/Services/LuceneIndexManager.cs
Outdated
Show resolved
Hide resolved
Add IsPublishing flag on PublishContentContext to handle when unpublishing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need unit tests to make sure all scenarios work with the DefaultContentManager. Because, while testing this I needed to also fix the use case when we unpublish a content item which was not removing the content item in the index. I'm approving, but we need unit tests.
Does this still need triage, @Skrypt? It seems it was actually triaged, with an all-start reviewer team being there. |
I believe it still needs proper unit tests. If we want to merge then we need to at least create a task/ticket/issue about Lucene Unit Tests. |
What do we need the triage for, exactly? Because then we don't merge the PR until it has unit tests. |
Ok, so no merge untill we have proper unit tests just like we said before. |
@hyzx86 can you write a unit test for this to finalize this PR Let me know if you need help |
This comment was marked as outdated.
This comment was marked as outdated.
@hishamco, @Skrypt I need help ! 😅 Do we currently have a way to check that all indexing tasks in the system have been completed? But I noticed that will always be some data in this table, I don't know if it is because the unit tests will not wait for |
As I looked at the code the
Which unit test do you refer to? |
…into lucenePublish
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Out of diff range and nitpick comments (1)
test/OrchardCore.Tests/Apis/ContentManagement/DeploymentPlans/ContentStepLuceneQueryTests.cs (1)
Line range hint
1-59
: Ensure consistent use of namespaces and imports.The file includes multiple namespaces and using directives. Ensure that all these are necessary for the current test implementations to avoid unnecessary dependencies and to keep the code clean and maintainable.
test/OrchardCore.Tests/Apis/ContentManagement/DeploymentPlans/ContentStepLuceneQueryTests.cs
Outdated
Show resolved
Hide resolved
{ | ||
Name = "CheckIndexingTask", | ||
Template = "Select Count(1) as Total from IndexingTask" | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hishamco , Here ,
Looks like I found another Bug, and here it will never work because of syntax errors
OrchardCore/src/OrchardCore.Modules/OrchardCore.Indexing/IndexingTaskManager.cs
Lines 133 to 141 in c967b5d
var deleteCmd = $"delete from {dialect.QuoteForTableName(table, _store.Configuration.Schema)} where {dialect.QuoteForColumnName("ContentItemId")} {dialect.InOperator("@Ids")};"; | |
do | |
{ | |
var pageOfIds = ids.Take(pageSize).ToArray(); | |
if (pageOfIds.Length > 0) | |
{ | |
await transaction.Connection.ExecuteAsync(deleteCmd, new { Ids = pageOfIds }, transaction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently not, the logic here is only to prevent repeated insertions, and there is no code to clean up the index task after the task is completed 😢
|
||
//await contentManager.CreateAsync(firstContent); | ||
//var contentFromDb = await contentManager.GetAsync(firstContent.ContentItemId); | ||
//Assert.NotNull(contentFromDb); faild |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Skrypt
Our content item operation is a bit complicated~~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Piedone ,need your help , I don't know how to do this unit test..
#15601 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's your question, specifically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as @Skrypt mentioned in this issue at #15601 ,
I understand that we should verify the impact on indexing functionality by separately testing Create, Update, Draft, and Publish actions with ContentManager.
However, based on the current design of DefaultContentManager
which requires calling a sequence of methods to save data to the database and trigger Lucene indexing, it seems difficult if not impossible to isolate tests for just the Create and Update actions.
All that aside, am I currently unit testing the right way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to test DefaultContentManager
or have a full indexing test. Rather, unit tests on LuceneIndexingContentHandler
with mocks is sufficient. I.e, the tests need to check that LuceneIndexingContentHandler
behaves correctly based on what it calls on the mocks.
If you search for "mock.setup" and "mock.verify" in the codebase, you'll see how this works. A lot of tests do something similar.
This pull request has merge conflicts. Please resolve those before requesting a review. |
It seems that this pull request didn't really move for quite a while. Is this something you'd like to revisit any time soon or should we close? Please comment if you'd like to pick it up. |
Closing this pull request because it has been stale for very long. If you think this is still relevant, feel free to reopen it. |
try to fix #13071
Summary by CodeRabbit