Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25216

An error is logged by the Solr indexer when an attachment is deleted while its page is being indexed

    XMLWordPrintable

Details

    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      Steps to reproduce

      1. Add an attachment to a page
      2. Delete it (or delete the page) right after, before the Solr indexer processed the page update triggered by the addition

      For example, with the REST API: attach a file then delete it immediately.

      Expected

      Nothing is logged: the attachment doesn't exist anymore, and its deletion updates the Solr index anyway.

      Actual

      The Solr indexer, which indexes a version of the page still listing the attachment, fails to read its content and logs an error with a full stack trace:

      ERROR .DocumentSolrMetadataExtractor - Failed to retrieve the content of attachment [Attachment xwiki:XWiki.DefaultSkin@icons.xwiki.favicon144.png]
      com.xpn.xwiki.XWikiException: Error number 3002 in 3: The attachment [Attachment xwiki:XWiki.DefaultSkin@icons.xwiki.favicon144.png] (file ...) could not be found in the filesystem attachment store.
      

      or

      ERROR .DocumentSolrMetadataExtractor - Failed to retrieve the content of attachment [Attachment xwiki:WikisResourceIT.testAttachmentsOrder@testAttachmentsOrderAbc.txt]
      org.xwiki.store.UnexpectedException: Failed to get InputStream
      ...
      Caused by: org.xwiki.store.blob.BlobNotFoundException: Blob not found at path: ...
      

      The index ends up correct (SolrIndexEventListener handles the attachment and document deletion events), so this error is misleading. It's seen on CI with the functional tests which delete the attachments they create right after using them (WikiSkinIT#overrideFaviconWithSkinAttachment, WikisResourceIT#testAttachmentsOrder), and can happen in any test or real usage doing the same.

      Proposed fix

      In AbstractSolrMetadataExtractor#getContentAsText, when the content cannot be read, check whether the attachment still exists in the stored document: if not, log it at debug level only. The error is kept when the attachment still exists, since its content is then really missing or broken (e.g. XWIKI-16203).

      Attachments

        Issue Links

          Activity

            People

              surli Simon Urli
              surli Simon Urli
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: