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:
or
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). |