Details
-
Bug
-
Resolution: Fixed
-
Major
-
5.3
-
Unit
-
Unknown
-
N/A
-
N/A
-
Description
Steps to reproduce
- Add an attachment to a page
- 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
- relates to
-
XWIKI-16203 Failed to retrieve the content of attachment errors for subwiki when upgrading from XWiki 8.4.6 to XWiki 11.1 on FileSystem
-
- Closed
-
-
XWIKI-9309 Also search in attachments when type is DOCUMENT
-
- Closed
-