OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

ContentItem is randomly Indexed in only one Lucene Index

Open mariojsnunes opened this issue 3 years ago • 4 comments

Describe the bug

I have two Lucene Indexes:

  1. Content (only published)
  2. ContentManagement (latest)

On rare occasions, after updating an existing Article, it is only indexed on ContentManagement and disappears from the Content Index.

To Reproduce

  • I cannot reproduce this issue, it has been reported multiple times in production.
  • I've restored the DB point-in-time before and after the issue occured and could not reproduce locally.
    • I've confirmed on the DB the item has the flags Latest = 1 and Published = 1 when it disappears.
    • If I reindex the Content Index it will appear again.
  • I'm using an Azure Linux App Service.
  • There are no errors in the logs.
  • We are using IContentManager to publish the items... UpdateAsync followed by PublishAsync.

Expected behavior

The item is indexed in both Indexes

I understand this is a tricky one, I'm posting in case this happened to someone else, or if someone has any idea what's happening.

mariojsnunes avatar Jul 20 '22 07:07 mariojsnunes

If you are using the ContentManager to update your content item it should re-index properly. Are you updating the content item with the OrchardCore.Content API or is it done from a server-side ContentHandler?

Skrypt avatar Jul 20 '22 13:07 Skrypt

If you are using the ContentManager to update your content item it should re-index properly. Are you updating the content item with the OrchardCore.Content API or is it done from a server-side ContentHandler?

It's server-side code, where we use IContentManager. image image

Yeah and it is re-indexed most of the time, the issue happens rarely...

mariojsnunes avatar Jul 20 '22 13:07 mariojsnunes

Can you check if there is enough logging in the code where the indexing is done, and if so enable it? It might help identity the issue since there is no consistent repro.

sebastienros avatar Aug 04 '22 17:08 sebastienros

@mariojsnunes

At least you may need to also use ValidateAsync().

await contentManager.UpdateAsync(contentItem);

var result = await contentManager.ValidateAsync(contentItem);
if (result.Succeeded)
{
    await contentManager.PublishAsync(contentItem);
}

Hmm, here some code I'm using

var result = await contentManager.UpdateValidateAndCreateAsync(contentItem, VersionOptions.Published);
if (!result.Succeeded)
{
    throw new ValidationException(string.Join(", ", result.Errors));
}

jtkech avatar Aug 04 '22 18:08 jtkech