Umbraco to re-index data on background thread
Fixes issue with scopes being disposed or referenced incorrectly due to yield returns as this can capture a scope in the enumerator which will get passed to a background thread in Examine and cause some issues. We saw this issue in netcore but the issue must still exist in v8 but we don't visibly see it for some reason. The other issue is that the ValueSet lookup for content was done 3x when an IContent is saved and it should only be done 2x, one for published, one for unpublished. The other issue is that the data lookups to build a ValueSet are intended to be done on a background thread. This is the case in v7 because the IEnumerable is lazy and passed all the way down to Examine's background thread but this doesn't occur in v8 because we need to iterate/split that value set before it's sent to Examine so the ValueSet is eagerly built within the request. We can easily resolve this by using the background task manager and just pushing a task when IContent/IMedia/IMember is saved. This will return the execution to the UI quicker.
This commit is contained in:
@@ -62,7 +62,7 @@ namespace Umbraco.Examine
|
||||
/// <param name="onComplete"></param>
|
||||
protected override void PerformIndexItems(IEnumerable<ValueSet> values, Action<IndexOperationEventArgs> onComplete)
|
||||
{
|
||||
//We don't want to re-enumerate this list, but we need to split it into 2x enumerables: invalid and valid items.
|
||||
// We don't want to re-enumerate this list, but we need to split it into 2x enumerables: invalid and valid items.
|
||||
// The Invalid items will be deleted, these are items that have invalid paths (i.e. moved to the recycle bin, etc...)
|
||||
// Then we'll index the Value group all together.
|
||||
// We return 0 or 1 here so we can order the results and do the invalid first and then the valid.
|
||||
@@ -80,7 +80,7 @@ namespace Umbraco.Examine
|
||||
|| !validator.ValidateProtectedContent(path, v.Category))
|
||||
? 0
|
||||
: 1;
|
||||
});
|
||||
}).ToList();
|
||||
|
||||
var hasDeletes = false;
|
||||
var hasUpdates = false;
|
||||
@@ -99,7 +99,7 @@ namespace Umbraco.Examine
|
||||
{
|
||||
hasUpdates = true;
|
||||
//these are the valid ones, so just index them all at once
|
||||
base.PerformIndexItems(group, onComplete);
|
||||
base.PerformIndexItems(group.ToList(), onComplete);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user